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:
28
README.md
28
README.md
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user