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
package main | |
import ( | |
"syscall/js" | |
"time" | |
) | |
func addGreenClass(classes js.Value) { | |
if classes.Call("contains", "pink").Bool() { | |
classes.Call("remove", "pink") |
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
<div id="main" class="center"> | |
<h1>Webassembly tutorial<h1> | |
<h2 id="description">Sample 4 | Modifying the classes of an HTML element</h2> | |
<h3 id="simpleText" class="green">Hello my friend!</h3> | |
</div> |
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
package main | |
import ( | |
"syscall/js" | |
) | |
func main() { | |
document := js.Global().Get("document") | |
h2 := document.Call("createElement", "h2") |
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
<div id="main" class="center"> | |
<h1>Webassembly tutorial<h1> | |
</div> |
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
package main | |
import ( | |
"fmt" | |
"syscall/js" | |
"time" | |
) | |
func main() { | |
currentTime := time.Now().Format("2006-01-02 15:04:05") |
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
<div class="center"> | |
<h1>Webassembly tutorial<h1> | |
<h2 id="description"></h2> | |
</div> |
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
<script> | |
loadWasm("pos-tagging-service.sample1.wasm") | |
.then((wasm) => { | |
console.log("main.wasm is loaded 👋"); | |
}) | |
.catch((error) => { | |
console.log("ouch", error); | |
}); | |
</script> |
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
package main | |
func main() { | |
println("Hello my friend!") | |
} |
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
package main | |
import "fmt" | |
func bubbleSort[T int32 | float32](input []T) []T { | |
swapped := true | |
for swapped { | |
swapped = false | |
for i := 0; i < len(input)-1; i++ { | |
if input[i] > input[i+1] { |
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
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func echo[T any](v T) { | |
fmt.Printf("%v (%s)\n", v, reflect.TypeOf(v)) | |
} |