Skip to content

feat(functions):troubleshoot go version #4909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thomas-tacquet
Copy link
Collaborator

Your checklist for this pull request

Description

Please describe what you added or changed.


## Problem

My Go Serverless Function build failed with an error message about the wrong version.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
My Go Serverless Function build failed with an error message about the wrong version.
My Go Serverless Function build failed with an error message mentioning a wrong version.

Comment on lines +22 to +26
When deploying a Go function, build step can fail with an error about the version of code versus version of the runtime even if the version seems correct.

This is due to the `go.mod` directive that specify a `X.Y.Z` version where the `Z` version does not match.

This happens by default because in go toolchain, the `go mod init` command now adds the version.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When deploying a Go function, build step can fail with an error about the version of code versus version of the runtime even if the version seems correct.
This is due to the `go.mod` directive that specify a `X.Y.Z` version where the `Z` version does not match.
This happens by default because in go toolchain, the `go mod init` command now adds the version.
Go function deployment may fail during the build step with a version mismatch error, even if the runtime version appears to be correct.
This is due to the `go.mod` directive that specifies an `X.Y.Z` version where the `Z` patch version does not match the version of the selected runtime.
This happens by default because the `go mod init` command includes the full Go version (including the patch version), which can lead to this mismatch if your runtime only supports a different patch version.

Comment on lines +30 to +32
Remove the `Z` version from the gomod.

Wrong go.mod example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Remove the `Z` version from the gomod.
Wrong go.mod example:
Remove the `Z` version from the `go.mod` file. In the example below, `X` corresponds to `1`, `Y` to `24`, and `Z` to `1`.
Content of a `go.mod` file with an incorrect `X.Y.Z` (`1.24.1`) version.

go 1.24.1
```

Fixed:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fixed:
The example below shows the content of the `go.mod` file after we have remove the incorrect `Z` version:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants