2

我使用 AWS SAM 和 Golang 创建了一个 API。此 API 使用私有模块,两个 repos 都存在于 codecommit 上。我的 buildspec.yml 文件是这样的:

phases:
  install:
    commands:
      - echo installing SAM ...
      - pip install awscli aws-sam-cli
      # Debugging
      - go env | sort
      - pwd
      - find .

  pre_build:
    commands:
      - echo Installing dependencies ...
      # Fetch all dependencies
      - go clean -modcache
      - GOSUMDB=off go get git-codecommit.region.amazonaws.com/v1/repos/my-modules.git
      - echo Installing dependencies done
      - go get ./...

  build:
    commands:
      - echo Build stated on `date`
      - make
      - sam deploy --template-file $PACKGED_TEMPLATE --stack-name $STACK_NAME --capabilities $CAPABILITY --s3-bucket $S3_BUCKET

  post_build:
    commands:
      - echo Deployment completed on `date`

去环境 | 排序结果是:

GONOPROXY="git-codecommit.region.amazonaws.com/v1/repos/my-modules"
GONOSUMDB="git-codecommit.region.amazonaws.com/v1/repos/my-modules"
GOOS="linux"
GOPATH="/go:/codebuild/output/src161218396"
GOPRIVATE="git-codecommit.region.amazonaws.com/v1/repos/my-modules"
GOPROXY="https://proxy.golang.org,direct"

构建结果是一个错误:

[Container] 2020/10/22 03:31:20 Running command GOSUMDB=off go get git-codecommit.region.amazonaws.com/v1/repos/my-modules.git
go: git-codecommit.region.amazonaws.com/v1/repos/my-modules.git@v1.0.0: reading git-codecommit.region.amazonaws.com/v1/repos/my-modules.git/go.mod at revision v1.0.0: unknown revision v1.0.0

[Container] 2020/10/22 03:31:23 Command did not exit successfully GOSUMDB=off go get git-codecommit.region.amazonaws.com/v1/repos/my-modules.git exit status 1

my-modules 包在 codecommit 上并且有标签 v1.0.0 图片

我的模块/go.mod

module git-codecommit.region.amazonaws.com/v1/repos/my-modules.git

go 1.15

require (
    github.com/aws/aws-lambda-go v1.19.1
    github.com/aws/aws-sdk-go v1.35.10
)

无法找出此问题的原因。寻求帮助。

4

0 回答 0