似乎在$ GOROOT中搜索了第三方软件包

时间:2017-07-01 06:46:02

标签: go

我创建了我的第一个go项目并尝试使用一些外部包

import terminal "github.com/wayneashleyberry/terminal-dimensions"

我的项目位于/home/noname/Workspace/go/src/proj/proj.go

go env看起来不错

$ go env
GOARCH="amd64"
GOBIN="/home/noname/Workspace/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/noname/Workspace/go"
GORACE=""
GOROOT="/usr/lib/go-1.8"
GOTOOLDIR="/usr/lib/go-1.8/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build163861736=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

但是当我尝试运行它时,我看到了

$ go run proj.go 
# command-line-arguments
/usr/lib/go-1.8/pkg/tool/linux_amd64/link: cannot open file /usr/lib/go-1.8/pkg/linux_amd64/github.com/wayneashleyberry/terminal-dimensions.a: open /usr/lib/go-1.8/pkg/linux_amd64/github.com/wayneashleyberry/terminal-dimensions.a: no such file or directory

任何第三方库都不需要这个,我不明白为什么。似乎在$GOROOT中搜索第三方软件包,而软件包实际上恰好位于文档应该位于的位置

$ file $GOPATH/pkg/linux_amd64/github.com/wayneashleyberry/terminal-dimensions.a 
/home/noname/Workspace/go/pkg/linux_amd64/github.com/wayneashleyberry/terminal-dimensions.a: current ar archive

抱歉新手问题

编辑:

$ go run -x proj.go 
WORK=/tmp/go-build340740598
mkdir -p $WORK/_/home/noname/Workspace/go/src/proj/shell/_obj/
mkdir -p $WORK/_/home/noname/Workspace/go/src/proj/
cd /home/noname/Workspace/go/src/proj/shell
/usr/lib/go-1.8/pkg/tool/linux_amd64/compile -o $WORK/_/home/noname/Workspace/go/src/proj/shell.a -trimpath $WORK -p _/home/noname/Workspace/go/src/proj/shell -complete -buildid efa1c0a0a5d82b27eb41cb592f4cb626ff98c64f -D _/home/noname/Workspace/go/src/proj/shell -I $WORK -I /home/noname/Workspace/go/pkg/linux_amd64 -pack ./input.go ./shell.go
mkdir -p $WORK/command-line-arguments/_obj/
mkdir -p $WORK/command-line-arguments/_obj/exe/
cd /home/noname/Workspace/go/src/proj
/usr/lib/go-1.8/pkg/tool/linux_amd64/compile -o $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid b280c68738f8469c481a1c4c407f43b16a476fdc -D _/home/noname/Workspace/go/src/proj -I $WORK -I "" -pack ./proj.go
cd .
/usr/lib/go-1.8/pkg/tool/linux_amd64/link -o $WORK/command-line-arguments/_obj/exe/proj -L $WORK -L "" -w -extld=gcc -buildmode=exe -buildid=b280c68738f8469c481a1c4c407f43b16a476fdc $WORK/command-line-arguments.a
# command-line-arguments
/usr/lib/go-1.8/pkg/tool/linux_amd64/link: cannot open file /usr/lib/go-1.8/pkg/linux_amd64/github.com/wayneashleyberry/terminal-dimensions.a: open /usr/lib/go-1.8/pkg/linux_amd64/github.com/wayneashleyberry/terminal-dimensions.a: no such file or directory

EDIT2:

$ go list -f {{.Dir}} github.com/wayneashleyberry/terminal-dimensions
/home/noname/Workspace/go/src/github.com/wayneashleyberry/terminal-dimensions

0 个答案:

没有答案