generated from Lerking/golang-repo-template
Initial. /JL
This commit is contained in:
2
go.mod
2
go.mod
@@ -1,3 +1,5 @@
|
||||
module template
|
||||
|
||||
go 1.20
|
||||
|
||||
require github.com/webview/webview v0.0.0-20240422163931-93be13a101e5 // indirect
|
||||
|
2
go.sum
Normal file
2
go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
github.com/webview/webview v0.0.0-20240422163931-93be13a101e5 h1:YeAdzszxZAIYebts/ZGyJjEXCpQWv+XCJm/4F3QNQDE=
|
||||
github.com/webview/webview v0.0.0-20240422163931-93be13a101e5/go.mod h1:Zk81X+8/mp/MNoeJXXK4Noydn8pcea09e00dFfAwrxg=
|
38
main.go
38
main.go
@@ -1,7 +1,41 @@
|
||||
package main
|
||||
|
||||
import . "fmt"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/webview/webview"
|
||||
)
|
||||
|
||||
func getRoot(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Printf("got / request\n")
|
||||
io.WriteString(w, "Welcome to TimeCard!\n")
|
||||
}
|
||||
func getHello(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Printf("got /hello request\n")
|
||||
io.WriteString(w, "Hello, HTTP!\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
Println("I'm here!")
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", getRoot)
|
||||
mux.HandleFunc("/hello", getHello)
|
||||
|
||||
err := http.ListenAndServe("127.0.0.10:3333", mux)
|
||||
if errors.Is(err, http.ErrServerClosed) {
|
||||
fmt.Printf("server closed\n")
|
||||
} else if err != nil {
|
||||
fmt.Printf("error starting server: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
w := webview.New(false)
|
||||
defer w.Destroy()
|
||||
w.SetTitle("Basic Example")
|
||||
w.SetSize(480, 320, webview.HintNone)
|
||||
w.SetHtml("Thanks for using webview!")
|
||||
w.Run()
|
||||
}
|
||||
|
Reference in New Issue
Block a user