2018-10-21 18:20:05 +02:00
|
|
|
// +build js
|
2018-08-02 16:46:35 +02:00
|
|
|
|
2018-07-09 08:13:36 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"syscall/js"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-02-19 07:49:15 +01:00
|
|
|
// GOARCH=wasm GOOS=js /home/$yourusername/go1.16/bin/go build -mod=mod -o hello.wasm hello_go116.go
|
2020-05-05 21:07:56 +02:00
|
|
|
js.Global().Get("console").Call("log", "Hello Webassembly!")
|
2018-07-09 08:13:36 +02:00
|
|
|
message := fmt.Sprintf("Hello, the current time is: %s", time.Now().String())
|
|
|
|
js.Global().Get("document").Call("getElementById", "hello").Set("innerText", message)
|
|
|
|
}
|