norunners / vert

WebAssembly interop between Go and JS values.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compile errors with go1.14

inliquid opened this issue · comments

Was playing around the lib to probably cover some conversion cases, but unfortunately program using it doesn't compile:

go: finding module for package github.com/norunners/vert
go: found github.com/norunners/vert in github.com/norunners/vert v0.0.0-20190616030331-d9c8c2aacdf1
# github.com/norunners/vert
..\..\..\..\pkg\mod\github.com\norunners\vert@v0.0.0-20190616030331-d9c8c2aacdf1\assign.go:39:8: invalid operation: jv == js.Null() (struct containing [0]func() cannot be compared)
..\..\..\..\pkg\mod\github.com\norunners\vert@v0.0.0-20190616030331-d9c8c2aacdf1\assign.go:39:27: invalid operation: jv == js.Undefined() (struct containing [0]func() cannot be compared)

Thanks for the report, this should be an easy fix use the new Equals method for js.Value types.

@norunners:
I am also having similar errors:

GOOS=js GOARCH=wasm go build -o web/main.wasm cmd/web.go
# github.com/norunners/vert
../../../go/pkg/mod/github.com/norunners/vert@v0.0.0-20190616030331-d9c8c2aacdf1/assign.go:39:8: invalid operation: jv == js.Null() (struct containing [0]func() cannot be compared)
../../../go/pkg/mod/github.com/norunners/vert@v0.0.0-20190616030331-d9c8c2aacdf1/assign.go:39:27: invalid operation: jv == js.Undefined() (struct containing [0]func() cannot be compared)

package main

import (
	"github.com/norunners/vert"
)

type Data struct {
	Message string `js:"msg"`
}

func main() {

	v := vert.ValueOf(Data{
		Message: "Hello World!",
	})

	d := &Data{}
	_ = v.AssignTo(d)
}

go/pkg/mod/github.com/norunners/vert@v0.0.0-20210320050952-39b24b3cdf94/assign.go:39:8: invalid operation: jv == js.Null() (struct containing [0]func() cannot be compared)
go/pkg/mod/github.com/norunners/vert@v0.0.0-20210320050952-39b24b3cdf94/assign.go:39:27: invalid operation: jv == js.Undefined() (struct containing [0]func() cannot be compared)

Looks like the exact same issue with go 1.17 on windows. Is this package still being worked on, @norunners?

$ GOOS=js GOARCH=wasm go get -u github.com/norunners/vert
# github.com/norunners/vert
..\..\..\go\pkg\mod\github.com\norunners\vert@v0.0.0-20211225230156-7ab116f5f5e4\assign.go:39:8: invalid operation: jv == js.Null() (struct containing [0]func() cannot be compared)
..\..\..\go\pkg\mod\github.com\norunners\vert@v0.0.0-20211225230156-7ab116f5f5e4\assign.go:39:27: invalid operation: jv == js.Undefined() (struct containing [0]func() cannot be compared)

Thanks for the report @drognisep I'll take a look.

Thanks, @norunners! :)