Switches to native Go build info for versioning

Simplifies the version command and Makefile by removing manual ldflags injection. The application now relies entirely on Go's built-in VCS metadata embedding to extract version, commit, and date information, ensuring accurate reporting across all build methods.
This commit is contained in:
2026-04-11 15:06:11 +01:00
parent 6e21a0798a
commit 4155d78440
3 changed files with 37 additions and 63 deletions

View File

@@ -134,25 +134,27 @@ cd gitlocal
# Install dependencies
go mod download
# Build with version info (recommended - uses Makefile)
# Build the binary
make build
# Or install to $GOPATH/bin with version info
make install
# Build without version info (not recommended)
# or
go build -o gitlocal
# Check version that would be built
make version
# Install to $GOPATH/bin
make install
# or
go install
```
The Makefile automatically injects version information from git tags:
- `Version`: Git tag (e.g., `v0.1.0`) or commit hash if no tag exists
- `Commit`: Short commit hash
- `Date`: Build timestamp
**Version Information:**
Go automatically embeds version information from git when building. The `gitlocal version` command reads this embedded metadata to display:
- Version (from git tag, e.g., `v0.1.0`)
- Commit hash (short SHA)
- Build timestamp
**Note:** Version information is automatically included when installing via `go install` (no Makefile needed). The tool reads version info from Go's build metadata.
This works automatically for:
- `go install` (remote installation)
- `go build` (local builds)
- Pre-built binaries (when built from a git repo)
Check the version after installing:
```bash