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
Original file line number
Diff line number
Diff line change
@@ -112,7 +112,7 @@ Go (a.k.a., Golang) is a programming language first developed at Google. It is a
112
112
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:
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:
136
136
137
137
```console
138
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.16 go build -v
138
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.17 go build -v
139
139
```
140
140
141
141
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.
142
142
143
143
```console
144
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.16 make
144
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.17 make
145
145
```
146
146
147
147
## Cross-compile your app inside the Docker container
148
148
149
149
If you need to compile your application for a platform other than `linux/amd64` (such as `windows/386`):
150
150
151
151
```console
152
-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=386 golang:1.16 go build -v
152
+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=386 golang:1.17 go build -v
153
153
```
154
154
155
155
Alternatively, you can build for multiple platforms at once:
0 commit comments