How to correctly run test in Golang source code directory runtime?

217 views
Skip to first unread message

Chai Baoyang

unread,
Aug 28, 2020, 12:34:39 PM8/28/20
to golang-nuts
Hi All,
     I tried to run "go test -timeout 30s -run ^TestMemStats$" in the source directory runtime. But failed with error infomation below:
"error.go:7:8: use of internal package internal/bytealg not allowed
alg.go:8:2: use of internal package internal/cpu not allowed
atomic_pointer.go:8:2: use of internal package runtime/internal/atomic not allowed
chan.go:22:2: use of internal package runtime/internal/math not allowed
alg.go:9:2: use of internal package runtime/internal/sys not allowed"

My ENV listed below
```
runtime git:(a7acf9af07) ✗ pwd
/Users/byc/go/src/go/src/runtime
➜  runtime git:(a7acf9af07) ✗ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/byc/Library/Caches/go-build"
GOENV="/Users/byc/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/byc/.gvm/pkgsets/go1.13.8/global"
GOPRIVATE=""
GOROOT="/Users/byc/.gvm/gos/go1.13.8"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/byc/.gvm/gos/go1.13.8/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/byc/go/src/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vd/rxp_88ls0vx5_s23q8v7xyg80000gn/T/go-build370571100=/tmp/go-build -gno-record-gcc-switches -fno-common".
    Who can tell me how to run the test correctly?
```

Ian Lance Taylor

unread,
Aug 28, 2020, 1:25:24 PM8/28/20
to Chai Baoyang, golang-nuts
On Fri, Aug 28, 2020 at 9:35 AM Chai Baoyang <8830...@qq.com> wrote:
>
> Hi All,
> I tried to run "go test -timeout 30s -run ^TestMemStats$" in the source directory runtime. But failed with error infomation below:
> "error.go:7:8: use of internal package internal/bytealg not allowed
> alg.go:8:2: use of internal package internal/cpu not allowed
> atomic_pointer.go:8:2: use of internal package runtime/internal/atomic not allowed
> chan.go:22:2: use of internal package runtime/internal/math not allowed
> alg.go:9:2: use of internal package runtime/internal/sys not allowed"

This normally means that the "go" binary on your PATH had a GOROOT
that was not the same as the directory in which you ran "go test".

Ian
Reply all
Reply to author
Forward
0 new messages