Build error with Go

I’m stuck on stage #CE0 (Print number of tables)

When I am pushing my code to the tester, the following logs appear:

remote: ------------------------------------------------------------------------
remote:      ___            _          ___              __  _                   
remote:     / __\ ___    __| |  ___   / __\_ __  __ _  / _|| |_  ___  _ __  ___ 
remote:    / /   / _ \  / _` | / _ \ / /  | '__|/ _` || |_ | __|/ _ \| '__|/ __|
remote:   / /___| (_) || (_| ||  __// /___| |  | (_| ||  _|| |_|  __/| |   \__ 
remote:   \____/ \___/  \__,_| \___|\____/|_|   \__,_||_|   \__|\___||_|   |___/
remote:    Welcome to CodeCrafters! Your commit was received successfully.
remote: ------------------------------------------------------------------------
remote: Welcome back! Your first build could take slightly longer, please bear with us.
remote: Subsequent ones will be snappy ⚡
remote: Streaming build logs...
remote: [build] Starting build...
remote: [build] If you don't see logs for 60s+, please contact us at
remote: [build] Step 1 complete.
remote: [build] Step 2 complete.
remote: [build] Step 3 complete.
remote: [build] Step 4 complete.
remote: [build] Step 5 complete.
remote: [build] Step 6 complete.
remote: [build] Step 7 complete.
remote: [build] Step 8 complete.
remote: [build] Step 7 complete.
remote: [build] Step 9 complete.
remote: [build] Step 10 complete.
remote: [build] Step 11 complete.
remote: [build] Step 12 complete.
remote: [build] Step 13 complete.
remote: [build] > + go mod graph
remote: [build] > + awk '{if ($1 !~ "@") {print $2}}'
remote: [build] > + xargs -r go get
remote: [build] Step 14 complete.
remote: [build] > fetch
remote: [build] > fetch
remote: [build] > (1/13) Upgrading musl (1.2.4-r1 -> 1.2.4-r2)
remote: [build] > (2/13) Upgrading libcrypto3 (3.1.2-r0 -> 3.1.5-r0)
remote: [build] > (3/13) Upgrading libssl3 (3.1.2-r0 -> 3.1.5-r0)
remote: [build] > (4/13) Upgrading ca-certificates (20230506-r0 -> 20240226-r0)
remote: [build] > (5/13) Installing brotli-libs (1.0.9-r14)
remote: [build] > (6/13) Installing libunistring (1.1-r1)
remote: [build] > (7/13) Installing libidn2 (2.3.4-r1)
remote: [build] > (8/13) Installing nghttp2-libs (1.57.0-r0)
remote: [build] > (9/13) Installing libcurl (8.5.0-r0)
remote: [build] > (10/13) Installing curl (8.5.0-r0)
remote: [build] > (11/13) Installing libexpat (2.6.2-r0)
remote: [build] > (12/13) Installing pcre2 (10.42-r1)
remote: [build] > (13/13) Installing git (2.40.1-r0)
remote: [build] > Executing busybox-1.36.1-r2.trigger
remote: [build] > Executing ca-certificates-20240226-r0.trigger
remote: [build] > OK: 18 MiB in 25 packages
remote: [build] Step 15 complete.
remote: [build] Step 16 complete.
remote: [build] Step 17 complete.
remote: [build] Step 18 complete.
remote: [build] Step 20 complete.
remote: [build] Step 19 complete.
remote: [build] Build successful.
remote: Running tests on your code. Logs should appear shortly...
remote: Debug = true
remote: [tester::#CE0] Running tests for Stage #CE0 (Print number of tables)
remote: [tester::#CE0] Creating test database with 2 tables: test.db
remote: [tester::#CE0] $ ./ test.db .dbinfo
remote: [your_program] github/com/codecrafters-io/sqlite-starter-go/app/utils: cannot compile Go 1.22 code
remote: [tester::#CE0] Expected stdout to contain "number of tables: 2", got: ""
remote: [tester::#CE0] Test failed
remote: View our article on debugging test failures:
   7a228ff..37653bc  master -> master

As you can see in the logs, the build initially succeeds, but when the tester starts to execute the code, I get the cannot compile Go 1.22 code error, which I can’t seem to debug. My code works correctly when I build the CLI on my system and then run the executable with the .dbinfo and the next stage’s .tables command.

I had initially changed the go.mod file (added stretchr/testify to make writing unit tests easier), and it seemed to build without any errors in all the previous stages. Upon seeing this error, I reverted the go.mod to the one provided in the starter template, but the same error persists. Any help regarding this would be much appreciated!

Hey! Can anyone from the core team take a look at this? Please do let me know if you need some additional context to replicate the same.

Hey @EshaanAgg, I haven’t been able to look into this yet, but deleting the current repository and creating a new repository could be a quick workaround: Can I re-attempt a challenge in a different language? - CodeCrafters

I tried making a new repo and running the same code there. Received the same error.

Hey @EshaanAgg, I was able to replicate this. The bug was related to cmd/go: improve "toolchain not available" message when patch version is missing · Issue #66175 · golang/go · GitHub, which was fixed in 1.22.4. I’ve updated the version our test runner runs now - the fix seems to work on my test repository.

Could you confirm if this works for you?

Will mark as closed for now, please do let us know if you run into this again!

I can confirm that this worked for me as well. Thanks!

1 Like

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