Skip to content

Commit 5e978ef

Browse files
authored
Golang 1.18 (#2123)
1 parent bade72b commit 5e978ef

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

golang/content.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Go (a.k.a., Golang) is a programming language first developed at Google. It is a
1515
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):
1616

1717
```dockerfile
18-
FROM %%IMAGE%%:1.17
18+
FROM %%IMAGE%%:1.18
1919

2020
WORKDIR /usr/src/app
2121

@@ -41,27 +41,27 @@ $ docker run -it --rm --name my-running-app my-golang-app
4141
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:
4242

4343
```console
44-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:1.17 go build -v
44+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:1.18 go build -v
4545
```
4646

4747
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.
4848

4949
```console
50-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:1.17 make
50+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:1.18 make
5151
```
5252

5353
## Cross-compile your app inside the Docker container
5454

5555
If you need to compile your application for a platform other than `linux/amd64` (such as `windows/386`):
5656

5757
```console
58-
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=386 %%IMAGE%%:1.17 go build -v
58+
$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=386 %%IMAGE%%:1.18 go build -v
5959
```
6060

6161
Alternatively, you can build for multiple platforms at once:
6262

6363
```console
64-
$ docker run --rm -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:1.17 bash
64+
$ docker run --rm -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp %%IMAGE%%:1.18 bash
6565
$ for GOOS in darwin linux; do
6666
> for GOARCH in 386 amd64; do
6767
> export GOOS GOARCH

0 commit comments

Comments
 (0)