我想在我的项目中使用 spf13/cobra。
输入安装命令结果
$ go get -u github.com/spf13/cobra/cobra
go: downloading github.com/spf13/cobra v1.0.0
go: downloading github.com/spf13/cobra/cobra v0.0.0-20200826151851-02a0d2fbc9e6
go: github.com/spf13/cobra/cobra upgrade => v0.0.0-20200826151851-02a0d2fbc9e6
go get github.com/spf13/cobra/cobra: ambiguous import: found package github.com/spf13/cobra/cobra in multiple modules:
github.com/spf13/cobra v1.0.0 (/go/pkg/mod/github.com/spf13/cobra@v1.0.0/cobra)
github.com/spf13/cobra/cobra v0.0.0-20200826151851-02a0d2fbc9e6 (/go/pkg/mod/github.com/spf13/cobra/cobra@v0.0.0-20200826151851-02a0d2fbc9e6)
但找不到cobra
命令和二进制文件。
$ cobra
bash: cobra: command not found
$ ls -la $GOPATH/bin | grep cobra
// not found binary
这是我的环境。
$ go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vscode/.cache/go-build"
GOENV="/home/vscode/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/workspaces/[my-package-name]/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build068490139=/tmp/go-build -gno-record-gcc-switches"
并通过基于microsoft/vscode-remote-try-go 的容器进行开发。
如何将二进制文件安装到$GOPATH/bin
?