GitHub Pages: errors parsing go.mod: invalid go version

Newbie here (ish), recently updated from an older 0.90 verison to 1.23 and I’ve spent the last day trying to get my site published and live. GitHub - rodders99/rodders99.github.io: Hugo static site.

I had hugo working on github pages last year.

I have no idea what I’ve done (apart form updating to the latest release and extended), but when I try to run the github actions to deploy the hugo site to pages I get this error in github actions, under the Build Hugo section.

Run hugo \

go: errors parsing go.mod:

/home/runner/work/rodders99.github.io/rodders99.github.io/go.mod:3: invalid go version '1.22.0': must match format 1.23

Total in 34 ms

Error: failed to load modules: failed to download modules: failed to execute 'go [mod download -modcacherw]': failed to execute binary "go" with args [mod download -modcacherw]: go: errors parsing go.mod:

/home/runner/work/rodders99.github.io/rodders99.github.io/go.mod:3: invalid go version '1.22.0': must match format 1.23

*errors.errorString

Error: Process completed with exit code 1.

Go version 1.22.0
Hugo Extended : I’ve tried various version from 0.9 to 1.23. Previous .9 version was not extended.

My google foo is poor today because I can’t find the answer.

Any help appreciated… thanks

Your go.mod file… NO:

go 1.23.0

There’s no such thing as Go v1.23.0.

Should be:

go 1.22

Perhaps you were trying to upgrade to Hugo v0.123.4, which is something completely different.

If I were you I would:

  1. Delete the content of the .github/workflows directory
  2. Create a new empty file, .github/workflows/hugo.toml
  3. Copy what is shown in Step 6 of this page to the empty file you created in Step 2.
  4. Change the environment variable “HUGO_VERSION” to 0.123.4.
  5. Push your local changes to your repo.

I made those changes and pushed your site to my GitHub account. Looks fine:
https://jmooring.github.io/rodders99.github.io/

Did that, same error.

hugo: downloading modules …

go: errors parsing go.mod:

/home/runner/work/rodders99.github.io/rodders99.github.io/go.mod:3: invalid go version '1.22.0': must match format 1.23

hugo: collected modules in 2235 ms

Total in 2236 ms

Error: failed to load modules: failed to download modules: failed to execute 'go [mod download -modcacherw]': failed to execute binary "go" with args [mod download -modcacherw]: go: errors parsing go.mod:

/home/runner/work/rodders99.github.io/rodders99.github.io/go.mod:3: invalid go version '1.22.0': must match format 1.23

*errors.errorString

Error: Process completed with exit code 1.

See my previous comment. It work great.
https://jmooring.github.io/rodders99.github.io/

See this repo:
https://github.com/jmooring/rodders99.github.io

Works fine.

I suggest you compare whatever you’ve done to my example.

1 Like

I encountered this issue in the past, comment on this topic may helps.

go.mod:3: invalid go version ‘1.22.0’: must match format 1.23

must match format 1.23 is equals to must match format x.y, the message doesn’t require a specific version. Remove the extra parts from go directive from go.mod should work, i.e. go x.y.z to go x.y.

  • go 1.23.0 to go 1.23.
  • go 1.22.0 to go 1.22.

Thanks to @Razon

First of all I made no changes go.mod originally, so something broke between version.

However the syntactically correct answer is :slight_smile:

Edit go.mod and change the line that reads:

go 1.23.0 (note, no trailing full stop)

to

go 1.22 (note, again, no trailing full stop)

Thankyou everyone for your help

1 Like

And it’s broken again, I only added under /content, no other files were changed. Now getting this error:

hugo: downloading modules …

go: downloading go1.22 (linux/amd64)

go: download go1.22 for linux/amd64: toolchain not available

hugo: collected modules in 4361 ms

Total in 4363 ms

Error: failed to load modules: failed to download modules: failed to execute 'go [mod download -modcacherw]': failed to execute binary "go" with args [mod download -modcacherw]: go: downloading go1.22 (linux/amd64)

go: download go1.22 for linux/amd64: toolchain not available

*errors.errorString

Error: Process completed with exit code 1.

ok so I changed go.mod to read

go 1.19

And that seems to have sorted it.

If I remember correctly, recent versions of Hugo only support go 1.21 and above.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.