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 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 - 图1 参数字段goctl env - 图2 参数类型goctl env - 图3 是否必填goctl env - 图4 默认值goctl env - 图5 参数说明
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 - 图6 参数字段goctl env - 图7 参数类型goctl env - 图8 是否必填goctl env - 图9 默认值goctl env - 图10 参数说明
forcebooleanNOfalse静默安装组件,如果false,则安装每个组件前会弹出安装确认选项
verbosebooleanNOfalse是否输出执行日志