Skip to content

Instantly share code, notes, and snippets.

@Luigi-Pizzolito
Created January 19, 2025 17:11
Show Gist options
  • Save Luigi-Pizzolito/7ff5b8a7b0f327370e1589a04464bcfb to your computer and use it in GitHub Desktop.
Save Luigi-Pizzolito/7ff5b8a7b0f327370e1589a04464bcfb to your computer and use it in GitHub Desktop.
Web App as Native in Go
// 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