Skip to content

Instantly share code, notes, and snippets.

View ivancorrales's full-sized avatar
🐾
Doing what I love to do!

Iván Corrales Solera ivancorrales

🐾
Doing what I love to do!
View GitHub Profile
package main
import (
"syscall/js"
"time"
)
func addGreenClass(classes js.Value) {
if classes.Call("contains", "pink").Bool() {
classes.Call("remove", "pink")
<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>
package main
import (
"syscall/js"
)
func main() {
document := js.Global().Get("document")
h2 := document.Call("createElement", "h2")
<div id="main" class="center">
<h1>Webassembly tutorial<h1>
</div>
package main
import (
"fmt"
"syscall/js"
"time"
)
func main() {
currentTime := time.Now().Format("2006-01-02 15:04:05")
<div class="center">
<h1>Webassembly tutorial<h1>
<h2 id="description"></h2>
</div>
<script>
loadWasm("pos-tagging-service.sample1.wasm")
.then((wasm) => {
console.log("main.wasm is loaded 👋");
})
.catch((error) => {
console.log("ouch", error);
});
</script>
@ivancorrales
ivancorrales / main.go
Created April 28, 2022 16:40
WASM - Sample1
package main
func main() {
println("Hello my friend!")
}
@ivancorrales
ivancorrales / bubblesort.go
Last active April 13, 2022 02:36
bubble sort implementation
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] {
@ivancorrales
ivancorrales / main.go
Last active April 12, 2022 18:19
Go generics: any
package main
import (
"fmt"
"reflect"
)
func echo[T any](v T) {
fmt.Printf("%v (%s)\n", v, reflect.TypeOf(v))
}