You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: golang/README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ Go (a.k.a., Golang) is a programming language first developed at Google. It is a
142
142
The most straightforward way to use this image is to use a Go container as both the build and runtime environment. In your `Dockerfile`, writing something along the lines of the following will compile and run your project (assuming it uses `go.mod` for dependency management):
There may be occasions where it is not appropriate to run your app inside a container. To compile, but not run your app inside the Docker instance, you can write something like:
169
169
170
170
```console
171
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.24 go build -v
171
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.25 go build -v
172
172
```
173
173
174
174
This will add your current directory as a volume to the container, set the working directory to the volume, and run the command `go build` which will tell go to compile the project in the working directory and output the executable to `myapp`. Alternatively, if you have a `Makefile`, you can run the `make` command inside your container.
175
175
176
176
```console
177
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.24 make
177
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.25 make
178
178
```
179
179
180
180
## Cross-compile your app inside the Docker container
181
181
182
182
If you need to compile your application for a platform other than `linux/amd64` (such as `windows/386`):
183
183
184
184
```console
185
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=386 golang:1.24 go build -v
185
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=386 golang:1.25 go build -v
186
186
```
187
187
188
188
Alternatively, you can build for multiple platforms at once:
0 commit comments