This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
wasm-canvas-example/main.go

27 lines
471 B
Go

package main
import (
"embed"
"fmt"
"io/fs"
"net/http"
)
var (
//go:embed assets/index.html assets/main.wasm assets/wasm_exec.js
assetsFolder embed.FS
)
func main() {
f, err := fs.Sub(assetsFolder, "assets")
if err != nil {
panic(err)
}
fmt.Println("Opening server on http://localhost:8080")
err = http.ListenAndServe(":8080", http.StripPrefix("/", http.FileServer(http.FS(f))))
if err != nil {
fmt.Println("Failed to start server", err)
return
}
}