goplusjs / gopherjs Goto Github PK
View Code? Open in Web Editor NEWA compiler from Go to JavaScript
License: BSD 2-Clause "Simplified" License
A compiler from Go to JavaScript
License: BSD 2-Clause "Simplified" License
//go:linkname localname [importpath.name]
When trying to pull down goplujs/gopherjs v1.1.8
with go mod using go1.15, I am seeing the following error:
regenvanwalbeek@cldr-go♜ go mod vendor
github.com/Workiva/cldr-go/scripts imports
github.com/goplusjs/gopherjs imports
github.com/goplusjs/gopherjs/build imports
github.com/visualfc/goembed imports
github.com/visualfc/goembed/resolve imports
io/fs: package io/fs is not in GOROOT (/Users/regenvanwalbeek/dev/go/src/io/fs)
It looks like #13 introduced an import that relies on io/fs
, so go mod can't pull that down with go 1.15. It looks like the build flag doesn't impact go mod.
As a workaround we're continuing to use 1.1.7
//go:embed hello.txt
var hello string
current generate to
func init() {
hello = string(_hello_data_)
}
must change ast to
var hello = string(_hello_data_)
package main
import (
"fmt"
"reflect"
)
type student struct {
name string
}
func main() {
a := []student{student{"A"}, student{"B"}, student{"C"}}
v := reflect.ValueOf(a)
i := v.Index(0).Interface()
a[0] = student{"X"}
fmt.Println(a, i)
}
want [{X} {B} {C}] {A}
got [{X} {B} {C}] {X}
Go 1.16 embed demo
package main
import (
"embed"
"fmt"
)
//go:embed txt/hello.txt
var hello string
//go:embed txt/*
var fs embed.FS
func main() {
fmt.Println(hello)
fmt.Println(fs.ReadFile("txt/hello.txt"))
}
on a fresh install on macosx (m1 hw, Big Sur) does not work.
OS: macOS Big Sur 11.2.3
HW: Apple M1 8/8 - 16Gb.
go version : go.16.2 darwin/arm64
steps to reproduce the problem :
on fresh install, install gopherjs as per instructions : go get -u github.com/goplusjs/gopherjs, than try to build something with the usual "gopherjs build main.go" (main.go or whatever)
results :
../../../../../../src/syscall/syscall_darwin.go:225:25: undeclared name: libc_fstat64_trampoline
../../../../../../src/syscall/syscall_darwin.go:227:25: undeclared name: libc_fstatfs64_trampoline
../../../../../../src/syscall/syscall_darwin.go:231:25: undeclared name: libc_lstat64_trampoline
../../../../../../src/syscall/syscall_darwin.go:233:25: undeclared name: libc_stat64_trampoline
../../../../../../src/syscall/syscall_darwin.go:235:25: undeclared name: libc_statfs64_trampoline
../../../../../../src/syscall/syscall_darwin.go:239:25: undeclared name: libc_fstatat64_trampoline
Same result with "gopherjs server"
any suggestion how to fix or workaround the problem ?
thanks in advance
package main
import (
"fmt"
"reflect"
"unsafe"
)
type T [8]int
func main() {
var t1 T
var t2 [8]int
fmt.Println(unsafe.Sizeof(t1))
fmt.Println(unsafe.Sizeof(t2))
fmt.Println(reflect.TypeOf(t1).Size())
fmt.Println(reflect.TypeOf(t2).Size())
}
--- output ----
32
32
32
12
import _ "time/tzdata"
gopherjs server -a -v
success
gopherjs server -v
failed
test code
package main
import (
"log"
"time"
_ "time/tzdata"
)
func main() {
loc, err := time.LoadLocation("Asia/Baghdad")
log.Println(loc, err)
}
When trying to open a file in a test running on linux (ubuntu:trusty), I get a bad file descriptor
error. I've reproduced with both Go1.14 and Go1.15.
Error:
Error Trace:
Error: Received unexpected error:
open testFile.js: bad file descriptor
Test: TestReadFile
Example test:
package read_file_test
import (
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestReadFile(t *testing.T) {
f, err := os.Open("testFile.js")
require.NoError(t, err)
require.NotNil(t, f)
}
I don't run into this problem on darwin (tested on 10.14.6). I also don't have this problem when using github.com/gopherjs/gopherjs. Is it possible some of the file i/o is regressed in the goplusjs fork?
I reproduced this with both node 10.22.1 and 11.15.0
package main
import (
"bytes"
"io"
"log"
)
// A version of bytes.Buffer without ReadFrom and WriteTo
type Buffer struct {
bytes.Buffer
io.ReaderFrom // conflicts with and hides bytes.Buffer's ReaderFrom.
io.WriterTo // conflicts with and hides bytes.Buffer's WriterTo.
}
func main() {
b := new(Buffer)
var i interface{} = b
if v, ok := i.(io.WriterTo); ok {
log.Println("error", v)
}
}
---- output ------
error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.