goctl env

概述

goctl env 可以快速检测 goctl 的依赖环境,如果你的环境中缺少了 goctl 的依赖环境,goctl env 会给出相应的提示,当然,你可以可以通过 goctl env install 命令来安装缺失的依赖环境。

goctl env 帮助指令

  1. $ goctl env --help
  2. Check or edit goctl environment
  3. Usage:
  4. goctl env [flags]
  5. goctl env [command]
  6. Available Commands:
  7. check Detect goctl env and dependency tools
  8. install Goctl env installation
  9. Flags:
  10. -f, --force Silent installation of non-existent dependencies
  11. -h, --help help for env
  12. -v, --verbose Enable log output
  13. -w, --write strings Edit goctl environment
  14. Use "goctl env [command] --help" for more information about a command.

goctl env 指令

goctl env 可以快速查看当前关于 goctl 环境的一些变量,在用户反馈 bug 时可以将这些信息一并提供给维护人员。

  1. $ goctl env
  2. GOCTL_OS=darwin
  3. GOCTL_ARCH=arm64
  4. GOCTL_HOME=/Users/sh00414ml/.goctl
  5. GOCTL_DEBUG=False
  6. GOCTL_CACHE=/Users/sh00414ml/.goctl/cache
  7. GOCTL_EXPERIMENTAL=off
  8. GOCTL_VERSION=1.6.5
  9. PROTOC_VERSION=3.19.4
  10. PROTOC_GEN_GO_VERSION=v1.28.0
  11. PROTO_GEN_GO_GRPC_VERSION=1.2.0
goctl env - 图1 字段goctl env - 图2 默认值goctl env - 图3 参数说明
GOCTL_OS空字符串操作系统
GOCTL_ARCH空字符串系统架构
GOCTL_HOME空字符串goctl 配置目录
GOCTL_DEBUG空字符串是否开启 debug 模式,维护者使用,枚举值 Ture、False
GOCTL_CACHE空字符串缓存目录
GOCTL_EXPERIMENTALoff是否开启试验性功能,枚举值 on:开启,off: 关闭
GOCTL_VERSION空字符串goctl 版本
PROTOC_VERSION空字符串protoc 版本
PROTOC_GEN_GO_VERSION空字符串protoc_gen_go 插件版本,没有安装则无
PROTO_GEN_GO_GRPC_VERSION空字符串protoc_gen_go_grpc 插件版本,没有安装则无

goctl env check 指令

goctl env check 指令用于快速检测 goctl 的依赖环境是否准备好,如果你的环境中缺少了 goctl 的依赖环境,goctl env check 会给出相应的提示。

  1. $ goctl env check --help
  2. Detect goctl env and dependency tools
  3. Usage:
  4. goctl env check [flags]
  5. Flags:
  6. -h, --help help for check
  7. -i, --install Install dependencies if not found
  8. Global Flags:
  9. -f, --force Silent installation of non-existent dependencies
  10. -v, --verbose Enable log output
goctl env - 图4 参数字段goctl env - 图5 参数类型goctl env - 图6 是否必填goctl env - 图7 默认值goctl env - 图8 参数说明
ibooleanNOfalse安装依赖组件
forcebooleanNOfalse静默安装组件,如果false,则安装每个组件前会弹出安装确认选项
verbosebooleanNOfalse是否输出执行日志

示例示例

示例 1: 检测 goctl 依赖环境

  • goctl 环境依赖已经安装
  • goctl 环境依赖未安装
  1. $ goctl env check --verbose
  2. [goctl-env]: preparing to check env
  3. [goctl-env]: looking up "protoc"
  4. [goctl-env]: "protoc" is installed
  5. [goctl-env]: looking up "protoc-gen-go"
  6. [goctl-env]: "protoc-gen-go" is installed
  7. [goctl-env]: looking up "protoc-gen-go-grpc"
  8. [goctl-env]: "protoc-gen-go-grpc" is installed
  9. [goctl-env]: congratulations! your goctl environment is ready!
  1. $ goctl env check --verbose
  2. [goctl-env]: preparing to check env
  3. [goctl-env]: looking up "protoc"
  4. [goctl-env]: "protoc" is not found in PATH
  5. [goctl-env]: looking up "protoc-gen-go"
  6. [goctl-env]: "protoc-gen-go" is not found in PATH
  7. [goctl-env]: looking up "protoc-gen-go-grpc"
  8. [goctl-env]: "protoc-gen-go-grpc" is not found in PATH
  9. [goctl-env]: check env finish, some dependencies is not found in PATH, you can execute
  10. command 'goctl env check --install' to install it, for details, please execute command
  11. 'goctl env check --help'

示例 2: 检测 goctl 依赖环境并安装缺失的依赖环境

  • 不静默安装
  • 静默安装
  1. $ goctl env check --verbose --install
  2. [goctl-env]: preparing to check env
  3. [goctl-env]: looking up "protoc"
  4. [goctl-env]: "protoc" is not found in PATH
  5. [goctl-env]: do you want to install "protoc" [y: YES, n: No]
  6. y
  7. [goctl-env]: preparing to install "protoc"
  8. [goctl-env]: "protoc" is already installed in "/Users/keson/go/bin/protoc"
  9. [goctl-env]: looking up "protoc-gen-go"
  10. [goctl-env]: "protoc-gen-go" is not found in PATH
  11. [goctl-env]: do you want to install "protoc-gen-go" [y: YES, n: No]
  12. y
  13. [goctl-env]: preparing to install "protoc-gen-go"
  14. "protoc-gen-go" installed from cache
  15. [goctl-env]: "protoc-gen-go" is already installed in "/Users/keson/go/bin/protoc-gen-go"
  16. [goctl-env]: looking up "protoc-gen-go-grpc"
  17. [goctl-env]: "protoc-gen-go-grpc" is not found in PATH
  18. [goctl-env]: do you want to install "protoc-gen-go-grpc" [y: YES, n: No]
  19. y
  20. [goctl-env]: preparing to install "protoc-gen-go-grpc"
  21. "protoc-gen-go-grpc" installed from cache
  22. [goctl-env]: "protoc-gen-go-grpc" is already installed in "/Users/keson/go/bin/protoc-gen-go-grpc"
  23. [goctl-env]: congratulations! your goctl environment is ready!
  1. $ goctl env check --verbose --install --force
  2. [goctl-env]: preparing to check env
  3. [goctl-env]: looking up "protoc"
  4. [goctl-env]: "protoc" is not found in PATH
  5. [goctl-env]: preparing to install "protoc"
  6. "protoc" installed from cache
  7. [goctl-env]: "protoc" is already installed in "/Users/keson/go/bin/protoc"
  8. [goctl-env]: looking up "protoc-gen-go"
  9. [goctl-env]: "protoc-gen-go" is not found in PATH
  10. [goctl-env]: preparing to install "protoc-gen-go"
  11. "protoc-gen-go" installed from cache
  12. [goctl-env]: "protoc-gen-go" is already installed in "/Users/keson/go/bin/protoc-gen-go"
  13. [goctl-env]: looking up "protoc-gen-go-grpc"
  14. [goctl-env]: "protoc-gen-go-grpc" is not found in PATH
  15. [goctl-env]: preparing to install "protoc-gen-go-grpc"
  16. "protoc-gen-go-grpc" installed from cache
  17. [goctl-env]: "protoc-gen-go-grpc" is already installed in "/Users/keson/go/bin/protoc-gen-go-grpc"
  18. [goctl-env]: congratulations! your goctl environment is ready!

goctl env install 指令

goctl env install 指令其实和 goctl env check —install 的功能是一样的。

  1. $ goctl env install --help
  2. Goctl env installation
  3. Usage:
  4. goctl env install [flags]
  5. Flags:
  6. -h, --help help for install
  7. Global Flags:
  8. -f, --force Silent installation of non-existent dependencies
  9. -v, --verbose Enable log output
goctl env - 图9 参数字段goctl env - 图10 参数类型goctl env - 图11 是否必填goctl env - 图12 默认值goctl env - 图13 参数说明
forcebooleanNOfalse静默安装组件,如果false,则安装每个组件前会弹出安装确认选项
verbosebooleanNOfalse是否输出执行日志