GoLang错误合集

1: go 编译过程出现文件不存在错误

/usr/local/go/pkg/tool/linux_amd64/link: cannot open file /usr/local/go/pkg/linux_amd64/github.com/spf13/cobra.a: open /usr/local/go/pkg/linux_amd64/github.com/spf13/cobra.a: no such file or directory
解决方案: 
go build -pkgdir /home/marczahn/go/pkg/ -o main main.go
2:
Get www.google.com: unsupported protocol scheme ""

解决方案:

添加运行参数时候,需要对对应的url带上例如: http://www.google.com or https://www.google.com

3:

exec: "gcc": executable file not found in %PATH%

解决方案:

下载mingw64;https://sourceforge.net/projects/mingw-w64/;并配置相应的环境变量

4:

src\github.com\ethereum\go-ethereum\cmd\geth\main.go:152:3: undefined: initCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:153:3: undefined: importCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:154:3: undefined: exportCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:155:3: undefined: importPreimagesCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:156:3: undefined: exportPreimagesCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:157:3: undefined: copydbCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:158:3: undefined: removedbCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:159:3: undefined: dumpCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:161:3: undefined: accountCommand
src\github.com\ethereum\go-ethereum\cmd\geth\main.go:161:3: too many errors

解决方案:

run -> Edit Configurations -> Run kind 中将类型file改成package

5: go get无法安装google.golang.org等相关依赖包

git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
git clone https://github.com/golang/net.git $GOPATH/src/golang.org/x/net
git clone https://github.com/golang/text.git $GOPATH/src/golang.org/x/text

发布了99 篇原创文章 · 获赞 8 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/CodeAsWind/article/details/80273638