我想在项目中使用spf13/cobra。
spf13/cobra: A Commander for modern Go CLI interactions
输入安装命令结果

$ 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/[email protected]/cobra)
        github.com/spf13/cobra/cobra v0.0.0-20200826151851-02a0d2fbc9e6 (/go/pkg/mod/github.com/spf13/cobra/[email protected])
但找不到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

最佳答案

安装眼镜蛇发生器

go get github.com/spf13/cobra/cobra
更多信息:https://github.com/spf13/cobra/blob/master/cobra/README.md

关于go - spf13/cobra无法将二进制文件下载到$ GOPATH/bin,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63710830/

10-14 01:23