前提:所有异常,基于笔者开发环境Mac、部署环境Linux7
异常一:
这个异常,我查了国内、国外,没有几个能把这个问题讲清楚的。我这边记录一下。
maoshengchun@maoshengchuns-MacBook-Pro rancher % maoshengchun@maoshengchuns-MacBook-Pro rancher % go get # github.com/docker/docker/pkg/term ../../../pkg/mod/github.com/docker/docker@v1.4.2-0.20190924003213-a8608b5b67c7/pkg/term/tc.go:13:28: undefined: unix.SYS_IOCTL ../../../pkg/mod/github.com/docker/docker@v1.4.2-0.20190924003213-a8608b5b67c7/pkg/term/tc.go:18:28: undefined: unix.SYS_IOCTL ../../../pkg/mod/github.com/docker/docker@v1.4.2-0.20190924003213-a8608b5b67c7/pkg/term/termios_bsd.go:24:31: undefined: unix.SYS_IOCTL ../../../pkg/mod/github.com/docker/docker@v1.4.2-0.20190924003213-a8608b5b67c7/pkg/term/termios_bsd.go:37:31: undefined: unix.SYS_IOCTL maoshengchun@maoshengchuns-MacBook-Pro rancher % maoshengchun@maoshengchuns-MacBook-Pro rancher %
出现这种情况的问题。因为,报错这个项目适应环境为Linux,那么问题来了。我的开发环境是Mac。所以,我们需要调整编译输出Linux。
我安装完golang。本地环境参数:
maoshengchun@maoshengchuns-MacBook-Pro rancher % maoshengchun@maoshengchuns-MacBook-Pro rancher % go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/maoshengchun/Library/Caches/go-build" GOENV="/Users/maoshengchun/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="gitlab.research.com" GOMODCACHE="/Users/maoshengchun/Work/Go/GoWork/pkg/mod" GONOPROXY="gitlab.research.com" GONOSUMDB="gitlab.research.com" GOOS="linux" GOPATH="/Users/maoshengchun/Work/Go/GoWork" GOPRIVATE="gitlab.research.com" GOPROXY="https://goproxy.io,https://mirrors.aliyun.com/goproxy/,direct" GOROOT="/usr/local/Cellar/go@1.15/1.15.12/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go@1.15/1.15.12/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="0" GOMOD="/Users/maoshengchun/Work/Go/GoWork/src/github.com/rancher/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ly/tvn8y5l52jb9wdkzphn_m25r0000gn/T/go-build846120270=/tmp/go-build -gno-record-gcc-switches" maoshengchun@maoshengchuns-MacBook-Pro rancher %
因为我们需要配置输出的环境为Linux,需要在系统环境配置里面,配置:
#编译输出为:Linux系统 export GOOS=linux #Mac安装golang,默认输出为:darwin #export GOOS=darwin
参考:
Golang 交叉编译跨平台的可执行程序 (Mac、Linux、Windows )
附录golang几个特殊环境配置:
1、
主机操作系统和编译架构的名称。 $GOHOSTOS and $GOHOSTARCH The name of the host operating system and compilation architecture. These default to the local system's operating system and architecture. Valid choices are the same as for $GOOS and $GOARCH, listed above. The specified values must be compatible with the local system. For example, you should not set $GOHOSTARCH to arm on an x86 system.
2、
目标操作系统和编译架构的名称。 $GOOS and $GOARCH The name of the target operating system and compilation architecture. These default to the values of $GOHOSTOS and $GOHOSTARCH respectively (described below).
异常二:
[root@localhost rancher]# [root@localhost rancher]# go get go: errors parsing go.mod: /data/study/gostudy/src/github.com/rancher/rancher/go.mod:18:2: replace gitlab.research.com/CloudComputing/Cloud-Fundamation/Operation-Center/rancher/types.git: version "features/v4.1.0-normal" invalid: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /data/study/gostudy/pkg/mod/cache/vcs/1a149b94f32befaf9dbed81d8246d9c2618723bddf70eecd410808a5027b4823: exit status 128: error: RPC failed; result=22, HTTP code = 404 fatal: The remote end hung up unexpectedly [root@localhost rancher]#
本地git环境:
[root@localhost rancher]# git version git version 1.8.3.1 [root@localhost rancher]#
解决方式:
因为git版本太低,升级git版本
参考链接:
上一篇: 需要POS机、信用卡套现...
下一篇: 哲学数字3和A股哲学...