

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 Go 設定平行測試
<a name="sample-parallel-test-go"></a>

以下是在 Linux 平台上`buildspec.yml`使用 Go 顯示平行測試執行的 範例：

```
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` 資料夾內。