From 90e68cb786ffa6e4f53d192c1b908ecf124280ba Mon Sep 17 00:00:00 2001 From: gjahn <gregor.jahn@bht-berlin.de> Date: Sat, 25 Nov 2023 00:12:23 +0100 Subject: [PATCH] Rework README and add note on building static vs. dynamic binary --- Makefile | 1 + README.md | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 92ccb30..c5507ab 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,7 @@ $(BIN_DIR)/artifact.bin: .PHONY: build-linux build-linux: export GOOS := linux build-linux: export GOARCH := amd64 +build-linux: export CGO_ENABLED := 0 build-linux: $(BIN_DIR)/artifact.bin diff --git a/README.md b/README.md index 9ef0351..adb301f 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,22 @@ Webservice ========== -A Go-based simple web service meant to be the subject for any tutorial -or maybe even the project work. +A Go-based simple web service meant to be the subject of any tutorial +or even used the project work. -__Prerequisites:__ +#### Prerequisites: * Go toolchain (install via system package manager or [by hand](https://go.dev/doc/install)) -__Primary interactions:__ +#### Build 1. Install dependencies: `go get -t ./...` 2. Run locally: `go run .` 3. Execute unit tests: `go test -race -v ./...` 4. Build artifact: `go build -o ./artifact.bin ./*.go` -To build for another platform, set `GOOS` and `GOARCH`. For more details, -please refer to the `Makefile`. +To build for another platform, set `GOOS` and `GOARCH`. To yield a static binary (fully +self-contained, no dynamic linking) set `CGO_ENABLED=0`. For more details, please refer +to the [Makefile](./Makefile). -- GitLab