Skip to content

Upgrade Go to 1.24 #290

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

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiled_starters/go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ event loops, the Redis protocol and more.

# Passing the first stage

The entry point for your Redis implementation is in `app/server.go`. Study and
The entry point for your Redis implementation is in `app/main.go`. Study and
uncomment the relevant code, and push your changes to pass the first stage:

```sh
Expand All @@ -26,8 +26,8 @@ That's all!

Note: This section is for stages 2 and beyond.

1. Ensure you have `go (1.19)` installed locally
1. Ensure you have `go (1.24)` installed locally
1. Run `./your_program.sh` to run your Redis server, which is implemented in
`app/server.go`.
`app/main.go`.
1. Commit your changes and run `git push origin master` to submit your solution
to CodeCrafters. Test output will be streamed to your terminal.
File renamed without changes.
4 changes: 2 additions & 2 deletions compiled_starters/go/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the Go version used to run your code
# on Codecrafters.
#
# Available versions: go-1.22
language_pack: go-1.22
# Available versions: go-1.24
language_pack: go-1.24
2 changes: 1 addition & 1 deletion compiled_starters/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

module github.com/codecrafters-io/redis-starter-go

go 1.22
go 1.24.0
9 changes: 6 additions & 3 deletions dockerfiles/go-1.22.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.22-alpine
Comment on lines +1 to 2
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Base Image Version Mismatch

The Dockerfile is still using FROM golang:1.22-alpine, which does not reflect the PR objective of upgrading to Go 1.24. Consider updating the base image to:

-FROM golang:1.22-alpine
+FROM golang:1.24-alpine

If this file is intended to be updated as part of the overall Go upgrade, please make the necessary changes.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.22-alpine
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.24-alpine


# Ensures the container is re-built if go.mod or go.sum changes
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum"

WORKDIR /app

COPY go.mod go.sum ./
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app
Comment on lines +9 to +10
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Invalid COPY Flag Usage

The COPY command is using --exclude flags:

COPY --exclude=.git --exclude=README.md . /app

However, Hadolint reports an error (invalid flag: --exclude). To resolve this, consider moving these exclusions to a .dockerignore file and using a standard COPY command. For example, create or update a .dockerignore file with:

.git
README.md

And then modify the Dockerfile to:

-COPY --exclude=.git --exclude=README.md . /app
+COPY . /app

This approach will ensure the build context excludes the specified files without using unsupported flags.

🧰 Tools
🪛 Hadolint (2.12.0)

[error] 10-10: invalid flag: --exclude

(DL1000)


# Starting from Go 1.20, the go standard library is no loger compiled
# setting the GODEBUG environment to "installgoroot=all" restores the old behavior
# Starting from Go 1.20, the go standard library is no loger compiled.
# Setting GODEBUG to "installgoroot=all" restores the old behavior
RUN GODEBUG="installgoroot=all" go install std

RUN go mod download
16 changes: 16 additions & 0 deletions dockerfiles/go-1.24.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.24-alpine

# Ensures the container is re-built if go.mod or go.sum changes
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum"

WORKDIR /app

# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app
Comment on lines +9 to +10
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid COPY Flag Parameter

The COPY command on line 10 uses --exclude flags, which are not supported (as flagged by Hadolint). To exclude files like .git and README.md, please remove these flags from the instruction and instead configure a .dockerignore file in the repository root.

For example, you can apply the following diff:

-COPY --exclude=.git --exclude=README.md . /app
+COPY . /app

Then, create or update your .dockerignore file to include:

.git
README.md
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY . /app
🧰 Tools
🪛 Hadolint (2.12.0)

[error] 10-10: invalid flag: --exclude

(DL1000)


# Starting from Go 1.20, the go standard library is no loger compiled.
# Setting GODEBUG to "installgoroot=all" restores the old behavior
RUN GODEBUG="installgoroot=all" go install std

RUN go mod download
6 changes: 3 additions & 3 deletions solutions/go/01-jm1/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ event loops, the Redis protocol and more.

# Passing the first stage

The entry point for your Redis implementation is in `app/server.go`. Study and
The entry point for your Redis implementation is in `app/main.go`. Study and
uncomment the relevant code, and push your changes to pass the first stage:

```sh
Expand All @@ -26,8 +26,8 @@ That's all!

Note: This section is for stages 2 and beyond.

1. Ensure you have `go (1.19)` installed locally
1. Ensure you have `go (1.24)` installed locally
1. Run `./your_program.sh` to run your Redis server, which is implemented in
`app/server.go`.
`app/main.go`.
1. Commit your changes and run `git push origin master` to submit your solution
to CodeCrafters. Test output will be streamed to your terminal.
4 changes: 2 additions & 2 deletions solutions/go/01-jm1/code/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the Go version used to run your code
# on Codecrafters.
#
# Available versions: go-1.22
language_pack: go-1.22
# Available versions: go-1.24
language_pack: go-1.24
2 changes: 1 addition & 1 deletion solutions/go/01-jm1/code/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

module github.com/codecrafters-io/redis-starter-go

go 1.22
go 1.24.0
2 changes: 1 addition & 1 deletion solutions/go/01-jm1/explanation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The entry point for your Redis implementation is in `app/server.go`.
The entry point for your Redis implementation is in `app/main.go`.

Study and uncomment the relevant code:

Expand Down
6 changes: 3 additions & 3 deletions solutions/go/02-rg2/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ event loops, the Redis protocol and more.

# Passing the first stage

The entry point for your Redis implementation is in `app/server.go`. Study and
The entry point for your Redis implementation is in `app/main.go`. Study and
uncomment the relevant code, and push your changes to pass the first stage:

```sh
Expand All @@ -26,8 +26,8 @@ That's all!

Note: This section is for stages 2 and beyond.

1. Ensure you have `go (1.19)` installed locally
1. Ensure you have `go (1.24)` installed locally
1. Run `./your_program.sh` to run your Redis server, which is implemented in
`app/server.go`.
`app/main.go`.
1. Commit your changes and run `git push origin master` to submit your solution
to CodeCrafters. Test output will be streamed to your terminal.
4 changes: 2 additions & 2 deletions solutions/go/02-rg2/code/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the Go version used to run your code
# on Codecrafters.
#
# Available versions: go-1.22
language_pack: go-1.22
# Available versions: go-1.24
language_pack: go-1.24
2 changes: 1 addition & 1 deletion solutions/go/02-rg2/code/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

module github.com/codecrafters-io/redis-starter-go

go 1.22
go 1.24.0
2 changes: 1 addition & 1 deletion starter_templates/go/code/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

module github.com/codecrafters-io/redis-starter-go

go 1.22
go 1.24.0
4 changes: 2 additions & 2 deletions starter_templates/go/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
attributes:
required_executable: go (1.19)
user_editable_file: app/server.go
required_executable: go (1.24)
user_editable_file: app/main.go
Loading