使用此任务获取、生成或测试 Go 应用程序,或运行自定义 Go 命令。
语法
# Go v0
# Get, build, or test a Go application, or run a custom Go command.
- task: Go@0
  inputs:
    command: 'get' # 'get' | 'build' | 'test' | 'custom'. Required. Command. Default: get.
    #customCommand: # string. Required when command == custom. Custom command. 
    #arguments: # string. Arguments. 
  # Advanced
    #workingDirectory: # string. Working directory.
输入
              command
               - 
              命令
              string。 必填。 允许的值:get、build、test、custom。 默认值:get。
指定要运行的 Go 命令。 使用 Custom 运行此处未列出的命令。
              customCommand
               - 
              自定义命令
              string。 
              command == custom时是必需的。
要执行的自定义 Go 命令。 例如,若要执行 go version,请使用 version。
              arguments
               - 
              参数
              string。
所选命令的可选参数。 例如,对 go build 命令使用生成时参数。
              workingDirectory
               - 
              工作目录
              string。
要在其中运行命令的工作目录。 当为空时,将使用存储库(用于生成)或项目(对于发布)的根目录,即 $(System.DefaultWorkingDirectory)的值。
任务控制选项
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性。
输出变量
没有。
注解
使用此任务获取、生成或测试 Go 应用程序,或运行自定义 Go 命令。
例子
variables:
  GOBIN:  '$(GOPATH)/bin' # Go binaries path
  GOROOT: '/usr/local/go1.11' # Go installation path
  GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
  modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
steps:
- task: GoTool@0
  displayName: 'Use Go 1.10'
- task: Go@0
  displayName: 'go get'
  inputs:
    arguments: '-d'
- task: Go@0
  displayName: 'go build'
  inputs:
    command: build
    arguments: '-o "$(System.TeamProject).exe"'
- task: ArchiveFiles@2
  displayName: 'Archive files'
  inputs:
    rootFolderOrFile: '$(Build.Repository.LocalPath)'
    includeRootFolder: False
- task: PublishBuildArtifacts@1
  displayName: 'Publish artifact'
  condition: succeededOrFailed()