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
@@ -130,7 +130,7 @@ Go (a.k.a., Golang) is a programming language first developed at Google. It is a
130
130
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:
157
157
158
158
```console
159
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.22 go build -v
159
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.23 go build -v
160
160
```
161
161
162
162
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.
163
163
164
164
```console
165
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.22 make
165
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.23 make
166
166
```
167
167
168
168
## Cross-compile your app inside the Docker container
169
169
170
170
If you need to compile your application for a platform other than `linux/amd64` (such as `windows/386`):
171
171
172
172
```console
173
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=386 golang:1.22 go build -v
173
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=386 golang:1.23 go build -v
174
174
```
175
175
176
176
Alternatively, you can build for multiple platforms at once:
0 commit comments