无法安装 Go dep

无法安装 Go dep

我尝试dep ensure在 Ubuntu 16.04 上运行该命令,但系统无法找到该命令。当我运行sudo apt install dep或任何其他安装命令时,我总是在运行时收到此错误dep ensure

No command 'dep' found, did you mean:
 Command 'dp' from package 'speech-tools' (universe)
 Command 'iep' from package 'emboss' (universe)
 Command 'dwp' from package 'binutils' (main)
 Command 'dex' from package 'dex' (universe)
 Command 'rep' from package 'rep' (universe)
 Command 'delp' from package 'fp-utils-3.0.0' (universe)
 Command 'xep' from package 'pvm-examples' (universe)
dep: command not found

有人告诉我我需要 Ubuntu 18 才能运行dep,但我想知道如何在我当前的 Ubuntu 上安装它。谢谢。

答案1

要查看您使用的存储库中是否有可用的软件包,请键入apt-cache search depapt-cache search go-dep

Go dep 在 16.04 仓库中不可用。它可在18.04 仓库,因此“某人”至少部分正确。

也许你可以从安装Github

答案2

Ubuntu 16.04上go-dep的安装及使用:

在里面创建bin目录$GOPATH

cd $GOPATH
mkdir bin

现在下载编译后的dep文件。

curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh

dep文件从$GOPATH/go/bin复制到项目的根位置。

dep使用命令执行文件

./dep [command]

dep命令:

Usage: "dep [command]"

Commands:

  init     Set up a new Go project, or migrate an existing one
  status   Report the status of the project's dependencies
  ensure   Ensure a dependency is safely vendored in the project
  version  Show the dep version information
  check    Check if imports, Gopkg.toml, and Gopkg.lock are in sync

Examples:
  dep init                               set up a new project
  dep ensure                             install the project's dependencies
  dep ensure -update                     update the locked versions of all dependencies
  dep ensure -add github.com/pkg/errors  add a dependency to the project

Use "dep help [command]" for more information about a command.

答案3

你可以将它放在你的 PATH 中

curl -LO https://raw.githubusercontent.com/golang/dep/master/install.sh
chmod 700 install.sh
./install.sh
chmod +x $GOPATH/bin/dep
sudo mv $GOPATH/bin/dep /usr/local/bin/

这样你就可以从任何地方调用它dep

相关内容