我在 Go v. 1.15.8 darwin/amd64 中收到以下错误消息
main.go:8:2: cannot find package "github.com/google/subcommands" in any of:
/usr/local/go/src/github.com/google/subcommands (from $GOROOT)
/Users/user1/go/src/github.com/google/subcommands (from $GOPATH)
main.go 中的代码如下所示:
package main
import (
"flag"
"context"
"os"
"github.com/google/subcommands"
)
我知道子命令位于:https ://github.com/google/subcommands 与 git repo 在这里:https ://github.com/google/subcommands.git
但是我该如何安装呢?
当我做:
go get github.com/google/subcommands
我收到以下错误消息:
# cd .; git clone -- https://github.com/google/subcommands /Users/user1/go/src/github.com/google/subcommands
Cloning into '/Users/user1/go/src/github.com/google/subcommands'...
fatal: unable to access 'https://github.com/google/subcommands/': Could not resolve host: github.com
package github.com/google/subcommands: exit status 128
当我打开我的网络浏览器并转到:https ://github.com/google/subcommands/我可以看到没有问题的网页。那么为什么“go get”命令会遇到问题呢?
我究竟做错了什么?