Initial commit.

This commit is contained in:
2025-12-10 15:05:08 +01:00
commit 2c1b1ab38c
5 changed files with 30 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# Exclude binary files
test-version

13
build.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
VERSION=$(git describe --tags --always 2>/dev/null)
if [ ! -z "$VERSION" ]; then
echo "Building version: $VERSION"
LDFLAGS="-ldflags \"-X main.Version=$VERSION\""
else
echo "Building without version information"
LDFLAGS=""
fi
go build $LDFLAGS -o test-version .

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module version-go
go 1.25.5

9
main.go Normal file
View File

@@ -0,0 +1,9 @@
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
fmt.Printf("The version is %s\n", Version)
}

3
version.go Normal file
View File

@@ -0,0 +1,3 @@
package main
var Version string = "undefined"