Created
January 19, 2025 17:11
-
-
Save Luigi-Pizzolito/7ff5b8a7b0f327370e1589a04464bcfb to your computer and use it in GitHub Desktop.
Web App as Native in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// filepath: /<project folder>/main.go | |
package main | |
import ( | |
"embed" | |
"net/http" | |
webview "github.com/webview/webview_go" | |
) | |
//go:embed static/* | |
var content embed.FS | |
func main() { | |
// Serve static files | |
http.Handle("/", http.FileServer(http.FS(content))) | |
// Start the web server | |
go http.ListenAndServe(":3000", nil) | |
// Create a new webview window | |
w := webview.New(true) | |
defer w.Destroy() | |
w.SetTitle("Three.js App") | |
w.SetSize(800, 600, webview.HintNone) //HintNone, HintFixed, HintMin, HintMax // 800x600 // Set default size | |
w.Navigate("http://localhost:3000/static/index.html") // Entrypoint | |
w.Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment