Skip to content

Commit e055697

Browse files
authored
chore: update README
1 parent 5c0346c commit e055697

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

README.md

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@
55

66
Docker image for building Go binaries for **Windows** with MinGW-w64 toolchain based on official Go Docker image.
77

8-
The repository provides simple cross-compilation environment for windows 32 and 64bit builds.
8+
Image provides simple cross-compilation environment for windows 32 and 64bit builds.
99

1010
## Usage
1111

1212
You can pull Docker image with desired Go version from Docker Hub:
1313

14-
```bash
15-
docker pull x1unix/go-mingw:latest # or "1.17" for specific Go version
14+
```shell
15+
docker pull x1unix/go-mingw:latest # or "1.21" for specific Go version
1616
```
1717

18-
**Recommended:** Please take a look at [full project build example](example/sqlite-app) before starting to work.
18+
> [!TIP]
19+
> Please take a look at [full project build example](example/sqlite-app) before starting to work.
1920
2021
### Building Go applications inside container
2122

2223
Mount directory with app source and build it:
2324

24-
```bash
25+
```shell
2526
docker run --rm -it -v /YourPackageSrc:/go/work \
2627
-w /go/work \
2728
x1unix/go-mingw go build .
@@ -33,51 +34,51 @@ You will get compiled Windows binary.
3334

3435
To build a 32-bit executable, set `GOARCH=386` variable:
3536

36-
```bash
37+
```shell
3738
docker run --rm -it -e GOARCH=386 -v /YourPackageSrc:/go/work \
3839
-w /go/work \
3940
x1unix/go-mingw go build .
4041
```
4142

42-
**Recommended:** See full project build example [here](example/sqlite-app).
43+
> [!TIP]
44+
> See full project build example [here](example/sqlite-app).
4345
4446
### Go linker flags override
4547

46-
You can override Go linker flags and other flags by specifying environment variable for a container using `-e` option.
48+
Go linker and compiler flags can be specified using container environment variables via `-e` option.
4749

4850
**Example:**
4951

50-
```bash
52+
```shell
5153
docker exec -it
5254
-e LDFLAGS="-linkmode external -extldflags '-static -s -w'"
5355
...
5456
```
5557

56-
### Produced files ownership
58+
### Output files ownership
5759

58-
By default, the container starts as *root* user. It means, that all produced files
60+
By default, Go container starts as a *root* user. It means, that all produced files
5961
will be owned by `root:root` user.
6062

61-
To set files to be owned by your current user by default, you need to start
62-
the container with your current **uid/gid**.
63+
To set files to be owned by your current user by default, start the container with your current **uid/gid**.
6364

6465
Use `-u` flag to start container with different user/group id.
6566

66-
```bash
67+
```shell
6768
# Start container as other uid/gid
6869
docker exec --rm -it -u "$UID:$GID" ...
6970
```
7071

71-
**Attention:** we recommend to mount your host GOPATH and GOCACHE instead of
72-
separated volumes approach when using UID/GID other than root.
72+
> [!IMPORTANT]
73+
> For non-root container user, it is recommended to mount your host GOPATH and GOCACHE.
7374
7475
### Go Build Cache
7576

76-
In order to speed up build times and keep Go build cache, you can mount your Go build cache directory or create a separate Docker volume for it.
77+
In order to speed up build times and keep Go build cache, it is recommended to mount local Go build cache directory or create a separate Docker volume for it.
7778

78-
**Local GOPATH**
79+
**Mounting local GOPATH:**
7980

80-
```bash
81+
```shell
8182
docker run --rm -it \
8283
-u $UID \
8384
-v /YourPackageSrc:/go/work \
@@ -87,9 +88,9 @@ docker run --rm -it \
8788
x1unix/go-mingw go build .
8889
```
8990

90-
**Volume:**
91+
**Using Docker volume:**
9192

92-
```bash
93+
```shell
9394
# Create Docker volume
9495
docker volume create go-cache
9596

@@ -102,7 +103,8 @@ docker run --rm -it \
102103
x1unix/go-mingw go build .
103104
```
104105

105-
See [Docker volumes docs](https://docs.docker.com/storage/volumes/) for more info.
106+
> [!TIP]
107+
> See [Docker volumes docs](https://docs.docker.com/storage/volumes/) for more info.
106108
107109
### Go modules cache
108110

@@ -113,10 +115,12 @@ To do this, mount your GOPATH or Go modules directory (`$GOPATH/pkg`).
113115

114116
### Building custom Docker image
115117

116-
You can build image locally with specified Go version:
118+
Docker image can be rebuilt locally with a desired Go version:
117119

118-
```bash
119-
make image GO_VERSION=1.17
120+
```shell
121+
make image GO_VERSION=1.20
120122
```
121123

122-
Replace `1.17` with desired Go version.
124+
> [!IMPORTANT]
125+
> Replace `1.20` with desired Go version.
126+

0 commit comments

Comments
 (0)