I'm encountering an error with a recently-compiled golang compiler, but only as an unprivileged user. I'm hoping someone could provide advice on further troubleshooting ideas.
As root:
$ cd $HOME && pwd
/root
$ mkdir -pv $HOME/go/src/hello
/bin/mkdir: created directory 'go'
/bin/mkdir: created directory 'go/src'
/bin/mkdir: created directory 'go/src/hello'
$ cd go/src/hello
$ cat > hello.go << EOF
> package main
>
> import "fmt">
> func main() {
> fmt.Printf("hello, world\n")
> }
> EOF
$ go build
$ ls
hello hello.go
$ ./hello
hello, world
$ go run hello.go
hello, world
As an unprivileged user:
$ cd $HOME && pwd
/usr/src/libcap
$ mkdir -pv $HOME/go/src/hello
/bin/mkdir: created directory 'go'
/bin/mkdir: created directory 'go/src'
/bin/mkdir: created directory 'go/src/hello'
$ cd go/src/hello
$ cat > hello.go << EOF
> package main
>
> import "fmt">
> func main() {
> fmt.Printf("hello, world\n")
> }
> EOF
$ go build
can't load package: package libcap/go/src/hello: cannot find package "libcap/go/src/hello" in any of:
/usr/src/libcap/go/src/hello (from $GOROOT)
/usr/src/libcap/go/src/libcap/go/src/hello (from $GOPATH)
$ ls
hello.go
$ go run hello.go
go run: cannot run non-main package
System information:
$ go version
go version go1.12.2 gccgo (GCC) 9.2.0 linux/amd64
I'm running in an LFS chroot environment and first discovered the issue while compiling the libcap
package, which contains a go module, in chapter 6.28 of the 20200119-systemd book. The host is a Debian live cd:
$ uname -a
Linux debian 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 GNU/Linux
The go tests appear to be fairly nominal, with very few unexpected failures (command executed from gcc build directory):
$ ../contrib/test_summary | grep -A7 Summ > log
$ less log
...
=== go Summary ===
# of expected passes 7349
# of unexpected failures 1
# of expected failures 1
# of untested testcases 6
# of unsupported tests 1
/usr/src/gcc/gcc-9.2.0/build/gcc/gccgo version 9.2.0 (GCC)
--
...
=== gotools Summary ===
# of expected passes 216
# of unexpected failures 4
# of untested testcases 159
/usr/src/gcc/gcc-9.2.0/build/./gcc/gccgo version 9.2.0 (GCC)
--
...
=== libgo Summary ===
# of expected passes 178
# of unexpected failures 6
/usr/src/gcc/gcc-9.2.0/build/./gcc/gccgo version 9.2.0 (GCC)
--
=== libgomp Summary ===
# of expected passes 6458
# of expected failures 2
# of unsupported tests 349
/usr/src/gcc/gcc-9.2.0/build/./gcc/gccgo version 9.2.0 (GCC)
--
...