@@ -110,24 +110,27 @@ Directory structure for **project mode**:
110110
111111### Build / Compile
112112
113- ** ` gocar build [--release] [--target <os>/<arch>] [--help] ` **
113+ ** ` gocar build [--release] [--target <os>/<arch>] [--with-cgo] [-- help] ` **
114114
115115Build the executable:
116116
117117- ` gocar build ` builds a Debug binary (default)
118118- ` gocar build --release ` builds a Release binary (enables ` CGO_ENABLED=0 ` , ` ldflags="-s -w" ` , and ` -trimpath ` )
119119- ` gocar build --target <os>/<arch> ` cross-compiles for the specified platform
120120- ` gocar build --release --target <os>/<arch> ` cross-compiles in Release mode for the specified platform
121+ - ` gocar build --with-cgo ` forces CGO to be enabled (sets ` CGO_ENABLED=1 ` )
121122- ` gocar build --help ` shows help information
122123
123124Build behavior:
124125
125- | Mode | Equivalent command |
126- | ------------------ | ------------------------------------------------------------ |
127- | debug (default) | ` go build -o bin/<os>/<arch>/<appName> ./main.go ` |
128- | --release | ` CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o bin/<os>/<arch>/<appName> ./main.go ` |
129- | --target | ` GOOS=<os> GOARCH=<arch> go build -o bin/<os>/<arch>/<appName> ./main.go ` |
130- | --release --target | ` CGO_ENABLED=0 GOOS=<os> GOARCH=<arch> go build -ldflags="-s -w" -trimpath -o bin/<os>/<arch>/<appName> ./main.go ` |
126+ | Mode | Equivalent command |
127+ | ----------------------- | ------------------------------------------------------------ |
128+ | debug (default) | ` go build -o bin/<os>/<arch>/<appName> ./main.go ` |
129+ | --release | ` CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o bin/<os>/<arch>/<appName> ./main.go ` |
130+ | --target | ` GOOS=<os> GOARCH=<arch> go build -o bin/<os>/<arch>/<appName> ./main.go ` |
131+ | --release --target | ` CGO_ENABLED=0 GOOS=<os> GOARCH=<arch> go build -ldflags="-s -w" -trimpath -o bin/<os>/<arch>/<appName> ./main.go ` |
132+ | --with-cgo | ` CGO_ENABLED=1 go build -o bin/<os>/<arch>/<appName> ./main.go ` |
133+ | --release --with-cgo | ` CGO_ENABLED=1 go build -ldflags="-s -w" -trimpath -o bin/<os>/<arch>/<appName> ./main.go ` |
131134
132135Examples:
133136
@@ -144,6 +147,12 @@ gocar build --target linux/amd64
144147# Release cross-compile for Windows AMD64 (enables CGO_ENABLED=0, ldflags="-s -w" and trimpath)
145148gocar build --release --target windows/amd64
146149
150+ # Force enable CGO
151+ gocar build --with-cgo
152+
153+ # Release build with CGO enabled
154+ gocar build --release --with-cgo
155+
147156# Show help
148157gocar build --help
149158```
0 commit comments