go语言import时为什么都从github导入
发布网友
发布时间:2022-04-22 10:52
我来回答
共1个回答
热心网友
时间:2023-11-02 13:06
go/src/go-cve-dictionary-master
# mv subcommands-master /opt/go/src/subcommands
# mv net-master /opt/go/src/net
# mv go-sqlite3-master /opt/go/src/go-sqlite3
都放到了go/src目录下了,我还修改了go-cve-dictionary-master/main.go文件内容,如下所示:
import (
"flag"
"fmt"
"os"
"golang.org/x/net/context" 改为 逗context地
"github.com/google/subcommands" 改为 subcommands
"github.com/kotakanbe/go-cve-dictionary/commands" 改为 go-cve-dictionary/commands
"github.com/kotakanbe/go-cve-dictionary/version" 改为 go-cve-dictionary/version
_ "github.com/mattn/go-sqlite3" 改为 go-sqlite3
)
执行 # go install go-cve-dictionary-master 错误如下:
can't load package: /opt/go/src/go-cve-dictionary-master/main.go:14:2: non-standard import "github.com/mattn/go-sqlite3" in standard package "go-cve-dictionary-master"
go-cve-dictionary-master/main.go:11:2: cannot find package "go-cve-dictionary/commands" in any of:
/opt/go/src/vendor/go-cve-dictionary/commands (vendor tree)
/opt/go/src/go-cve-dictionary/commands (from $GOROOT)
/root/go/src/go-cve-dictionary/commands (from $GOPATH)
go-cve-dictionary-master/main.go:12:2: cannot find package "go-cve-dictionary/version" in any of:
/opt/go/src/vendor/go-cve-dictionary/version (vendor tree)
/opt/go/src/go-cve-dictionary/version (from $GOROOT)
/root/go/src/go-cve-dictionary/version (from $GOPATH)
subcommands/subcommands.go:29:2: cannot find package "golang.org/x/net/context" in any of:
/opt/go/src/vendor/golang.org/x/net/context (vendor tree)
/opt/go/src/golang.org/x/net/context (from $GOROOT)
/root/go/src/golang.org/x/net/context (from $GOPATH