

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 Go 配置并行测试
<a name="sample-parallel-test-go"></a>

以下是显示在 Linux 平台上使用 Go 执行并行测试的示例：`buildspec.yml`

```
version: 0.2

batch:
  fast-fail: false
  build-fanout:
    parallelism: 5
    ignore-failure: false

phases:
  install:
    commands:
      - echo 'Fetching Go version'
      - go version
  pre_build:
    commands:
      - echo 'prebuild'
  build:
    commands:
      - echo 'Running go Tests'
      - go mod init calculator
      - cd calc
      - |
        codebuild-tests-run \
         --test-command "go test -v calculator.go" \
         --files-search "codebuild-glob-search '**/*test.go'"
  post_build:
    commands:
      - echo "Test execution completed"
```

在上面的示例中，`calculator.go`函数包含用于测试的简单数学函数，所有测试文件和`calculator.go`文件都在`calc`文件夹中。