Skip to content
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

Upgrade Go to 1.24 #125

Merged
merged 1 commit 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
2 changes: 1 addition & 1 deletion compiled_starters/go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Time to move on to the next stage!

Note: This section is for stages 2 and beyond.

1. Ensure you have `go (1.16+)` installed locally
1. Ensure you have `go (1.24)` installed locally
1. Run `./your_program.sh` to run your program, which is implemented in
`app/main.go`.
1. Commit your changes and run `git push origin master` to submit your solution
Expand Down
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
4 changes: 2 additions & 2 deletions compiled_starters/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
// DON'T EDIT THIS!

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

go 1.22
go 1.24.0

require github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
14 changes: 8 additions & 6 deletions dockerfiles/go-1.22.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.22-alpine

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

WORKDIR /app

# Starting from Go 1.20, the go standard library is no loger compiled
# setting the GODEBUG environment to "installgoroot=all" restores the old behavior
# .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

As with the new Dockerfile, the COPY command here uses unsupported --exclude flags:

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

Recommended Action:
• Remove the unsupported flags and manage file exclusions via a .dockerignore file.
Apply this diff:

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

Ensure that .git and README.md are listed in .dockerignore to prevent cache misses.

📝 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

ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum"
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.

🛠️ Refactor suggestion

⚠️ Potential issue

Invalid COPY Flag Usage

The COPY command uses --exclude flags (i.e.

COPY --exclude=.git --exclude=README.md . /app
```) which is not a valid flag in Docker’s COPY command. Docker ignores such flags and external tools (like Hadolint) flag this as an error.  
**Suggested Resolution:**  
• Remove the `--exclude` flags from the COPY command and instead use a properly configured `.dockerignore` file to exclude `.git` and `README.md`.  
For example, update the Dockerfile diff as follows:  
```diff
-COPY --exclude=.git --exclude=README.md . /app
+COPY . /app

Then add a .dockerignore file at the repository root (if not already present) with the following entries:

.git
README.md
🧰 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
2 changes: 1 addition & 1 deletion solutions/go/01-dr6/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Time to move on to the next stage!

Note: This section is for stages 2 and beyond.

1. Ensure you have `go (1.16+)` installed locally
1. Ensure you have `go (1.24)` installed locally
1. Run `./your_program.sh` to run your program, which is implemented in
`app/main.go`.
1. Commit your changes and run `git push origin master` to submit your solution
Expand Down
4 changes: 2 additions & 2 deletions solutions/go/01-dr6/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
4 changes: 2 additions & 2 deletions solutions/go/01-dr6/code/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
// DON'T EDIT THIS!

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

go 1.22
go 1.24.0

require github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
4 changes: 2 additions & 2 deletions starter_templates/go/code/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
// DON'T EDIT THIS!

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

go 1.22
go 1.24.0

require github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
2 changes: 1 addition & 1 deletion starter_templates/go/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
attributes:
required_executable: go (1.16+)
required_executable: go (1.24)
user_editable_file: app/main.go
Loading