go语言git包的导入 go导入github

关于在go语言中导入当前文件夹的步骤【go语言git包的导入 go导入github】1.先把要导入go语言git包的导入的包go build - go install
2.接着在要导入go语言git包的导入的方法中以go语言git包的导入: 项目名 / 导入go语言git包的导入的文件名的形式导入即可(如下方test(项目名) / chiid(文件名))
go导入github包后无法导入本地包从问题上看有两方面的bug:
导入go自己的包出错
Golang还是很智能的,也提示了说是GOROOT未定义 , 循着这个思路就可以解决这个bug:
点击File—settings—GO—GOROOT(GOROOT其实就是go语言安装的所在目录)
我安装在D盘,选择好路径之后,点击OK就可以了:
像这样可以看到,导入go自己的包已经不报错啦,第一个bug解决 。
go语言import时为什么都从github导入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
关于go语言git包的导入和go导入github的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息 , 记得收藏关注本站 。

    推荐阅读