go 编译报unexpected directory layout 错误

Adelaide ·
更新时间:2024-11-14
· 885 次阅读

今天编译agent时,发现报如下错误

make
go build -buildmode=pie -tags "" -o kata-agent \
        -ldflags "-X main.version=1.9.0-rc0-ba6ab83c16cc3df8d188118e1555ba66958f6a87 -X main.seccompSupport=no "
unexpected directory layout:
        import path: github.com/docker/docker/pkg/parsers
        root: /root/golang/src
        dir: /root/golang/src/github.com/kata-containers/agent/vendor/github.com/docker/docker/pkg/parsers
        expand root: /root/golang/src
        expand dir: /root/golang/src/github.com/kata-containers/agent/vendor/github.com/docker/docker/pkg/parsers
        separator: /
make: *** [kata-agent] Error 1
 

原因是之前修改了go的环境变量export PATH="$PATH:$GOROOT/bin:$GOPATH:$GOPATH/go/bin"

解决办法修改/etc/profile

#go env
export GOROOT=/usr/local/go
export GOPATH=/root/golang
export PATH="$PATH:$GOROOT/bin"


作者:YYQSH



GO directory

需要 登录 后方可回复, 如果你还没有账号请 注册新账号