modulepackage
0.0.9
Repository: https://github.com/talentlessguy/go-web-app.git
Documentation: pkg.go.dev
# README
Simple CLI for setting up Go WebAssembly frontend app.
What's included
- š ļø Dev Server with live reload
- šļø TinyGo for small WebAssembly output
- ā” Git setup with files (such as
README.md
) - 𩹠Glue files (
index.html
+wasm_exec.js
)
Requirements
- Go 1.12+
- Browser that supports WebAssembly
lld
(LLVM linker)
Install
go get github.com/talentlessguy/go-web-app
Then use as go-web-app
.
CLI Reference
go-web-app init <app name>
Initialize a project in a picked directory.
Project tree
out.wasm
is generated when building. Other files are automatically added.
āāā src
ā āāā main.go
āāā build
ā āāā out.wasm
āāā go.mod
āāā index.html
āāā README.md
āāā wasm_exec.js
go-web-app dev --port <port>
Builds the project on first run and launches a development server with specified port.
Default port is 8080.
After launching a server, you should go to http://localhost:<port>
Every time you change a file in src
dev server automatically compiles and updates the page.
go-web-app build
Compiles go code to WebAssembly. Compiled out.wasm
file could be found in build
folder.
Everything in src
compiles to build
, every go file.
After build, binary size is shown
# Functions
CompileToWASM - compile go code to wasm with tinygo.
CompileToWASMCLI - the same as CompileToWASM but for CLI.
InitWebApp - create a project with files.
RunDevServer - launches a server for hosting html page with wasm_exec and fetched wasm binaries.