Initial. /JL
Some checks are pending
Go / build (1.19.x) (push) Waiting to run
Go / build (1.20.x) (push) Waiting to run

This commit is contained in:
Jan Lerking
2024-04-23 08:33:37 +02:00
parent 21e3097d26
commit 0ef7f49b80
3 changed files with 40 additions and 2 deletions

2
go.mod
View File

@@ -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
View 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
View File

@@ -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()
}