(more immediately relevant is probably https://golang.org/pkg/go/build/#Default, but it documents the same behavior)
On Tue, Mar 9, 2021 at 8:52 AM Axel Wagner <axel.wagner...@googlemail.com> wrote: > https://golang.org/pkg/runtime/#GOROOT > > GOROOT returns the root of the Go tree. It uses the GOROOT environment >> variable, if set at process start, or else the root used during the Go >> build. > > > I don't understand how you expect a binary to find GOROOT otherwise, if > you don't set the environment variable. > > On Tue, Mar 9, 2021 at 6:38 AM tapi...@gmail.com <tapir....@gmail.com> > wrote: > >> I have two machines, their GOROOTs are different. >> I build a binary on one machine then transfer the binary to the other. >> It runs well on the machine the binary is produced on, but fails on the >> other. >> >> The code reporting the error is >> >> unsafePkg, err := build.Import("unsafe", "", build.FindOnly) >> if err != nil { >> log.Fatal(fmt.Errorf("build.Import: %w", err)) >> } >> >> The error is >> >> build.Import: go/build: go list unsafe: exit status 2 >> go: cannot find GOROOT directory: /home/myname/path/of/GOROOT >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/c02407eb-2fec-4195-8ef3-46a33e233c66n%40googlegroups.com >> <https://groups.google.com/d/msgid/golang-nuts/c02407eb-2fec-4195-8ef3-46a33e233c66n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEX%2BdsY_WUj3mYZUf%2BAOusv_kD%2BuUA44vdXBGoSJ2N9jA%40mail.gmail.com.