这篇文章上次修改于 1517 天前,可能其部分内容已经发生变化,如有疑问可询问作者。
~ go get -u github.com/gin-gonic/gin
go: github.com/gin-gonic/gin upgrade => v1.6.3
go: github.com/golang/protobuf upgrade => v1.4.3
go: github.com/ugorji/go/codec upgrade => v1.2.0
go: github.com/modern-go/reflect2 upgrade => v1.0.1
go: gopkg.in/yaml.v2 upgrade => v2.3.0
go: github.com/json-iterator/go upgrade => v1.1.10
go: github.com/modern-go/concurrent upgrade => v0.0.0-20180306012644-bacd9c7ef1dd
go: golang.org/x/sys upgrade => v0.0.0-20201119102817-f84b799fce68
go: github.com/go-playground/validator/v10 upgrade => v10.4.1
go: google.golang.org/protobuf upgrade => v1.25.0
go: golang.org/x/crypto upgrade => v0.0.0-20201117144127-c1f2f97bffc9
如果报错请参考如下设置
报的错误忘记截图了...
报的错误内容大概如下:
# runtime/cgo
In file included from gcc_darwin_amd64.c:6:
/usr/local/include/pthread.h:331:6: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
/usr/local/include/pthread.h:200:2: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
/usr/local/include/pthread.h:331:6: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
/usr/local/include/pthread.h:200:34: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
/usr/local/include/pthread.h:540:6: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
/usr/local/include/pthread.h:200:2: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
/usr/local/include/pthread.h:540:6: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
/usr/local/include/pthread.h:200:34: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
配置下zshrc
code ~/.zshrc
# GOPATH
export GO111MODULE=on
export GOPATH=/Users/USERNAME/go:/Users/USERNAME/go_project/go_learning
export GOROOT=/usr/local/go/
# 添加下面这一行就可以了
export CGO_CPPFLAGS="-Wno-error -Wno-nullability-completeness -Wno-expansion-to-defined -Wno-builtin-requires-header"
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH:$GOROOT:$GOBIN
export GOPROXY=https://goproxy.cn,direct
没有评论