Aws-codebuild-docker-images: Add support for Go 1.16

Created on 17 Feb 2021  路  10Comments  路  Source: aws/aws-codebuild-docker-images

Since Go 1.16 was released, I would love to have this available in the Codebuild images.

Blog Post:
https://blog.golang.org/go1.16

version update

Most helpful comment

Since the images have not been updated since >2 month: What is the recommended way to use Go in Codebuild? Ignore the provided versions and install it on our own?

We would like to rely on the AWS provided images, for performance and compliance reasons.

All 10 comments

Would be great to see this! Thanks!

Is there any ETA on this?

Since the images have not been updated since >2 month: What is the recommended way to use Go in Codebuild? Ignore the provided versions and install it on our own?

We would like to rely on the AWS provided images, for performance and compliance reasons.

The recommendation by the AWS support was to directly use goenv which is also used internally and is provided in the images.

To manually invoke goenv from CodeBuild, see https://github.com/syndbg/goenv/blob/master/COMMANDS.md

@msiuts thanks for sharing that!

FYI anyone interested - add something like this to your buildspec file command before you run any go commands:

      - 'goenv install 1.16.3'
      - 'goenv local 1.16.3'
      - 'go build ...something'

You can see available versions with goenv install --list. At the time of writing 1.16.4 and 1.16.5 were released but did not yet work with this method, I'm unsure on how long it usually takes for the version to become installable with goenv. Anyone know why it's not fully up to date?

Ahh here we go:
You need to pull the latest version of goenv, then you install the latest from their repo

add to buildspec commands:

      # Update goenv to get latest definitions of go version, see
      # https://github.com/syndbg/goenv/tree/master/plugins/go-build
      # https://github.com/syndbg/goenv/tree/master/plugins/go-build/share/go-build
      - 'cd $HOME/.goenv && git pull --ff-only && cd -'
      - 'goenv install 1.16.4'
      - 'goenv local 1.16.4'
      - 'go version'

@shogo82148 Merged upstream 馃檱

@syndbg Thanks!

@ AWS CodeBuild Team, can you re-build the images?

@shogo82148 You don't need wait for AWS to update the images, you should be able to access 1.16.5 by using the commands in your buildspec listed above. The first command updates the goevn locally so that it can install the latest version that goenv has built and then the other commands activate it for your build.

      - 'cd $HOME/.goenv && git pull --ff-only && cd -'
      - 'goenv install 1.16.5'
      - 'goenv local 1.16.5'
      - 'go version'

This will work for whatever version goenv supports without AWS updating docker images

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rdehnhardt picture rdehnhardt  路  5Comments

alanivey picture alanivey  路  3Comments

npetter picture npetter  路  5Comments

rvdwijngaard picture rvdwijngaard  路  6Comments

jfromaniello picture jfromaniello  路  5Comments