微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Go Migration不会在MacOS上安装

如何解决Go Migration不会在MacOS上安装

此处为Mac OS。我在~/go下本地安装了Go版本go1.14.2 darwin / amd64,在我的~/.bash_profile中,我有

export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:/Users/myuser/workspace/myproject/repos
export PATH="$GOPATH/bin:$PATH"

export GOPATH=/Users/myuser/workspace/myproject/repos

export PATH=$PATH:/Users/myuser/workspace/myproject/repos/bin

我正在尝试使go migrate工作。当我跑步时:

go get -tags 'postgres' -u github.com/golang-migrate/migrate/v4/cmd/migrate

我得到:

$ go migrate
go migrate: unkNown command

因此,我然后尝试下载binary directly off of GitHub并将其复制到/Users/myuser/workspace/myproject/repos/bin/

$ ls -al ~/myuser/myproject/repos/bin/
total 391744
drwxr-xr-x  22 myuser  staff       704 Sep 22 12:41 .
drwxr-xr-x  18 myuser  staff       576 Aug 20 05:41 ..
-rwxr-xr-x   1 myuser  staff  18485484 Jun 15 12:38 dlv
-rwxr-xr-x   1 myuser  staff   6790688 Jun 15 12:38 fillstruct
-rwxr-xr-x   1 myuser  staff   4588168 Jun 15 12:37 go-outline
-rwxr-xr-x   1 myuser  staff   4385080 Jun 15 12:37 go-symbols
-rwxr-xr-x   1 myuser  staff  13219700 Jun 15 12:37 gocode
-rwxr-xr-x   1 myuser  staff  12768972 Jun 15 12:38 gocode-gomod
-rwxr-xr-x   1 myuser  staff   9168808 Jun 15 12:38 godef
-rwxr-xr-x   1 myuser  staff   8031416 Jun 15 12:38 godoctor
-rwxr-xr-x   1 myuser  staff   5851000 Jun 15 12:38 goimports
-rwxr-xr-x   1 myuser  staff   6301816 Jun 15 12:38 golint
-rwxr-xr-x   1 myuser  staff   4678536 Jun 15 12:37 gomodifytags
-rwxr-xr-x   1 myuser  staff   5448568 Jun 15 12:37 gopkgs
-rwxr-xr-x   1 myuser  staff   7438724 Jun 15 12:38 goplay
-rwxr-xr-x   1 myuser  staff   6291392 Jun 15 12:37 gorename
-rwxr-xr-x   1 myuser  staff   7990696 Jun 15 12:38 goreturns
-rwxr-xr-x   1 myuser  staff  13191844 Jun 15 12:37 gotests
-rwxr-xr-x   1 myuser  staff   9443888 Jun 15 12:37 guru
-rwxr-xr-x   1 myuser  staff   6060712 Jun 15 12:37 impl
-rwxr-xr-x@  1 myuser  staff  41461192 Aug  3 21:34 migrate.darwin-amd64
-rwxr-xr-x   1 myuser  staff   7896368 Jun 25 05:27 mockgen

但仍然,当我运行go migrate时,我得到了错误

$ go migrate
go migrate: unkNown command

考虑到我已下载的位置以及我确实不想更改的所有路径设置,如何成功安装go migrate并使其从命令行运行?


当我跑步时:

$ which migrate
$ 

因此未安装。

解决方法

它实际上称为which migrate,您可以通过运行command -v migratemigrate.darwin-amd64来检查其位置,或者从bin文件夹matches中调用二进制文件

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。