run test failed in WSL
I download xgo by install.sh
curl -fsSL https://github.com/xhd2015/xgo/raw/master/install.sh | bash
And when I run:
xgo test -run TestMethodMock ./mock_tcp_conn
I got error:
fork/exec /Users/xhd2015/installed/go1.21.7/bin/go: no such file or directory
Maybe something wrong with build-release
Okey I'll test it using docker later.
Can you build it using --local and try again?
got another error:
# cmd/compile/internal/xgo_rewrite_internal/patch
internal/xgo_rewrite_internal/patch/trap.go:96:22: invalid operation: cannot index fn.Type().Params() (value of type *types.Type)
exit status 1
Seems a regression.Can you try it with go1.22.1? I'll deliver a fix later
I seems I wrote some wrong code, Not it work well in both 1.20.5 and 1.22.1
Sounds good, thanks for your feedback!
Maybe should fix install script or build-release
cmd/compile/internal/xgo_rewrite_internal/patch
internal/xgo_rewrite_internal/patch/trap.go:96:22: invalid operation: cannot index fn.Type().Params() (value of type *types.Type) exit status 1
I can reproduce this error with go1.19, it should be easy to fix.
I got error: fork/exec /Users/xhd2015/installed/go1.21.7/bin/go: no such file or directory Maybe something wrong with build-release
As for this, I cannot reproduce. I just tested the example in README.md in a refresh docker container. The test passed.
Not sure if it is related to windows or WSL.
I got error: fork/exec /Users/xhd2015/installed/go1.21.7/bin/go: no such file or directory Maybe something wrong with build-release
As for this, I cannot reproduce. I just tested the example in README.md in a refresh docker container. The test passed.
Not sure if it is related to windows or WSL.
Are you use curl -fsSL https://github.com/xhd2015/xgo/raw/master/install.sh | bash to download xgo?
Are you use curl -fsSL https://github.com/xhd2015/xgo/raw/master/install.sh | bash to download xgo?
Yes.
Steps to reproduce a successful installation on Linux:
curl -fsSL https://github.com/xhd2015/xgo/raw/master/install.sh | bash
export PATH=~/.xgo/bin:$PATH
git clone https://github.com/xhd2015/xgo
cd xgo
# this may take a while for initial setup
xgo test -v ./test/xgo_test/...
Output:
=== RUN TestTrapSet
--- PASS: TestTrapSet (0.00s)
PASS
ok github.com/xhd2015/xgo/test/xgo_test/link_on_init_finished 0.046s
=== RUN TestMemEqual
--- PASS: TestMemEqual (0.00s)
PASS
ok github.com/xhd2015/xgo/test/xgo_test/mem_equal 0.003s
=== RUN TestMethodShouldHaveFMSuffix
--- PASS: TestMethodShouldHaveFMSuffix (0.00s)
PASS
ok github.com/xhd2015/xgo/test/xgo_test/method_fm_suffix 0.002s
=== RUN TestMethodRecvValueShouldBeCopied
--- PASS: TestMethodRecvValueShouldBeCopied (0.00s)
PASS
ok github.com/xhd2015/xgo/test/xgo_test/method_recv_value 0.024s
=== RUN TestMethodValueCompare
--- PASS: TestMethodValueCompare (0.00s)
PASS
ok github.com/xhd2015/xgo/test/xgo_test/method_value_cmp 0.003s
=== RUN TestRewriteChallenge
--- PASS: TestRewriteChallenge (0.00s)
PASS
ok github.com/xhd2015/xgo/test/xgo_test/rewrite_challenge 0.023s
=== RUN TestTrapSet
--- PASS: TestTrapSet (0.00s)
PASS
ok github.com/xhd2015/xgo/test/xgo_test/trap_set 0.023s
Steps to reproduce a successful installation on Linux:
curl -fsSL https://github.com/xhd2015/xgo/raw/master/install.sh | bash export PATH=~/.xgo/bin:$PATH git clone https://github.com/xhd2015/xgo cd xgo # this may take a while for initial setup xgo test -v ./test/xgo_test/...Output:
=== RUN TestTrapSet --- PASS: TestTrapSet (0.00s) PASS ok github.com/xhd2015/xgo/test/xgo_test/link_on_init_finished 0.046s === RUN TestMemEqual --- PASS: TestMemEqual (0.00s) PASS ok github.com/xhd2015/xgo/test/xgo_test/mem_equal 0.003s === RUN TestMethodShouldHaveFMSuffix --- PASS: TestMethodShouldHaveFMSuffix (0.00s) PASS ok github.com/xhd2015/xgo/test/xgo_test/method_fm_suffix 0.002s === RUN TestMethodRecvValueShouldBeCopied --- PASS: TestMethodRecvValueShouldBeCopied (0.00s) PASS ok github.com/xhd2015/xgo/test/xgo_test/method_recv_value 0.024s === RUN TestMethodValueCompare --- PASS: TestMethodValueCompare (0.00s) PASS ok github.com/xhd2015/xgo/test/xgo_test/method_value_cmp 0.003s === RUN TestRewriteChallenge --- PASS: TestRewriteChallenge (0.00s) PASS ok github.com/xhd2015/xgo/test/xgo_test/rewrite_challenge 0.023s === RUN TestTrapSet --- PASS: TestTrapSet (0.00s) PASS ok github.com/xhd2015/xgo/test/xgo_test/trap_set 0.023s
I try this in another WSL and got same error, maybe WSL problem?
WSL may be a slightly different linux, I'll test this tonight.
And may also test on cygwin (windows is kind of complex...)
curl -fsSL https://github.com/xhd2015/xgo/raw/master/install.sh | bash export PATH=~/.xgo/bin:$PATH git clone https://github.com/xhd2015/xgo cd xgo # this may take a while for initial setup xgo test -v ./test/xgo_test/...
Hello @WAY29 , I tried on WSL , and again, everything works fine.
You can also run xgo test --log-debug -v ./test/xgo_test/... to see what will happen.
P.S. The build script seems fine.
got another error by install script xgo:
❯ xgo test --log-debug -v ./test/xgo_test/...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x64194b]
goroutine 1 [running]:
os/exec.(*ExitError).Error(...)
/home/xhd2015/installed/go1.22.1/src/os/exec/exec.go:869
main.main()
/tmp/xgo2556559935/src/cmd/xgo/main.go:99 +0x6ab
However go run ./script/build-release --local build xgo is work fine.
I think your xgo release should not be compiled on the local machine but should use github action to prevent some compilation information (such as username xhd2015) from appearing.
routine 1 [running]: os/exec.(*ExitError).Error(...) /home/xhd2015/installed/go1.22.1/src/os/exec/exec.go:869 main.main() /tmp/xgo255
For this one, do you have the debug.log?
I think your xgo release should not be compiled on the local machine but should use github action to prevent some compilation information (such as username xhd2015) from appearing.
I have created the issue https://github.com/xhd2015/xgo/issues/10 to follow on this
I think your xgo release should not be compiled on the local machine but should use github action to prevent some compilation information (such as username xhd2015) from appearing.
Now build-release includes a -trimpath flag, see https://github.com/xhd2015/xgo/commit/c16fef5bf0691ecb53ce936332a854debd48d8f8.
It's output will look like:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x123171d]
goroutine 1 [running]:
os/exec.(*ExitError).Error(...)
os/exec/exec.go:862
main.main()
github.com/xhd2015/xgo/cmd/xgo/main.go:44 +0xbd
The go doc at https://pkg.go.dev/cmd/go#:~:text=trimpath says:
-trimpath
remove all file system paths from the resulting executable.
Instead of absolute file system paths, the recorded file names
will begin either a module path@version (when using modules),
or a plain import path (when using the standard library, or GOPATH).
I re-run above steps and all work fine.
However it seems new version of xgo need to SET GOROOT ENV or set --with-goroot option manually? Can't it get GOROOT by go env GOROOT?
However it seems new version of xgo need to SET GOROOT ENV or set --with-goroot option manually? Can't it get GOROOT by
go env GOROOT?
Can you run with --log-debug to see what's the env in the log? Because it actually init GOROOT from runtime, if that not found, then it will ask for the --with-goroot option.
However it seems new version of xgo need to SET GOROOT ENV or set --with-goroot option manually? Can't it get GOROOT by
go env GOROOT?Can you run with
--log-debugto see what's the env in the log? Because it actually init GOROOT from runtime, if that not found, then it will ask for the --with-goroot option.
I run with --log-debug and no debug.log created.Just got message: requires GOROOT or --with-goroot
Ok that should be simple to reproduce. I think the situation should be that, you have go on your PATH variable, but does not have set GOROOT.
So $GOROOT is empty, however go env GOROOT is fine.
Can you verify that on your machine?
Ok that should be simple to reproduce. I think the situation should be that, you have
goon your PATH variable, but does not have set GOROOT. So$GOROOTis empty, howevergo env GOROOTis fine.Can you verify that on your machine?
Yes, as you say.
This has been fixed in v1.0.8