You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I see the following error when compiling a program with tinygo. Is it unsupported by design?
❯ tinygo build -o hello ./main.go
# github.com/cespare/xxhash
../../../go/pkg/mod/github.com/cespare/[email protected]/xxhash_unsafe.go:27:11: cannot use len(s) (value of type int) as uintptr value in assignment
../../../go/pkg/mod/github.com/cespare/[email protected]/xxhash_unsafe.go:28:11: cannot use len(s) (value of type int) as uintptr value in assignment
In short, the code is not portable. However, in this case it's easy to work around it. This slightly changed version also compiles under TinyGo, by using the fact that StringHeader and SliceHeader all use the same type for the Len and Cap fields:
funcSum64String(sstring) uint64 {
// See https://groups.google.com/d/msg/golang-nuts/dcjzJy-bSpw/tcZYBzQqAQAJ// for some discussion about this unsafe conversion.varb []bytebh:= (*reflect.SliceHeader)(unsafe.Pointer(&b))
sh:= (*reflect.StringHeader)(unsafe.Pointer(&s))
bh.Data=sh.Databh.Len=sh.Lenbh.Cap=sh.LenreturnSum64(b)
}
Hi, I see the following error when compiling a program with tinygo. Is it unsupported by design?
Source: https://github.com/cespare/xxhash/blob/569f7c8abf1f58d9043ab804d364483cb1c853b6/xxhash_unsafe.go#L27
I also saw similar issues in https://github.com/tidwall/gjson/blob/5c2e4b382486589dad7478130a364ee2fa6a068b/gjson_ngae.go#L74
The text was updated successfully, but these errors were encountered: