[root@localhost go-zero-admin]# GOPROXY=https://goproxy.cn/,direct go install github.com/zeromicro/go-zero/tools/goctl@latest
go: downloading github.com/zeromicro/go-zero/tools/goctl v1.3.8
go: downloading github.com/zeromicro/go-zero v1.3.4
go: downloading github.com/zeromicro/go-zero v1.3.2
go: downloading go.opentelemetry.io/otel/trace v1.3.0
go: downloading go.opentelemetry.io/otel v1.3.0
go: downloading github.com/logrusorgru/aurora v2.0.3+incompatible
go: downloading github.com/spf13/cobra v1.4.0
go: downloading go.uber.org/automaxprocs v1.4.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9
go: downloading github.com/spaolacci/murmur3 v1.1.0
go: downloading github.com/iancoleman/strcase v0.2.0
go: downloading github.com/go-sql-driver/mysql v1.6.0
go: downloading github.com/emicklei/proto v1.10.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/fatih/structtag v1.2.0
go: downloading github.com/zeromicro/antlr v0.0.1
go: downloading github.com/lib/pq v1.10.4
go: downloading github.com/prometheus/client_golang v1.11.0
go: downloading go.opentelemetry.io/otel/exporters/jaeger v1.3.0
go: downloading go.opentelemetry.io/otel/exporters/zipkin v1.3.0
go: downloading go.opentelemetry.io/otel/sdk v1.3.0
go: downloading google.golang.org/grpc v1.44.0
go: downloading google.golang.org/protobuf v1.27.1
go: downloading github.com/zeromicro/ddl-parser v1.0.3
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/common v0.30.0
go: downloading github.com/go-logr/logr v1.2.2
go: downloading github.com/openzipkin/zipkin-go v0.4.0
go: downloading github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/prometheus/procfs v0.7.3
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
go: downloading github.com/go-logr/stdr v1.2.2
[root@localhost go-zero-admin]# ls
client
[root@localhost go-zero-admin]# goctl
-bash: goctl: 未找到命令
经过检查 在gopath的可执行文件目录bin下找到了goctl 说明命令已经下载成功,但是跟系统的路径没有做关联,所以 检查可执行文件的路径为:
/mnt/hgfs/workplace/bin
环境变量未找到可执行文件,所以编辑环境文件将上述路径写入profile文件
[root@localhost bin]# vi /etc/profile
# go安装怒路
export GOROOT=/usr/local/go
# GOPATH环境变量
export GOPATH=/mnt/hgfs/workplace
# 依赖包代理服务器
export GOPROXY=https://goproxy.io
# 开启go mod 模式
export GO111MODULE=on
# go可执行程序导入到系统环境变量
export PATH=$PATH:/usr/local/go/bin
#本路径为安装的三方go库可执行文件目录
export PATH=$PATH:/mnt/hgfs/workplace/bin
[root@localhost bin]# source /etc/profile