From d8c4ad29d4337fbd2cafd54eefe2af559a0f0e39 Mon Sep 17 00:00:00 2001 From: Slawomir Koszewski Date: Wed, 10 Dec 2025 20:48:43 +0100 Subject: [PATCH] Add README.md. --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e6ae7f5 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# Go Application Versioning + +This repository contains a simple Go application that demonstrates how to embedded version strings that come from Git tags during the build process. + +The `version.go` source contains a variable named `Version` that is initialized in the code to `undefined` string constant. +The build command replaces this values with Git tag value optionally suffixed with information about changes since the tag. + +The build command uses the `-ldflags` option of the `go build` command to set the value of the `Version` variable at compile time. + +```go +go build -o testver -ldflags "-X main.Version=$(VERSION)" +``` + +The version is captured using the following command: + +```shell +VERSION=$(git describe --tags --always) +``` + +Use `make` command to build the application. \ No newline at end of file