gebn / go-stamp Goto Github PK
View Code? Open in Web Editor NEWStamp adds version information to a Bazel-built Go library.
License: MIT License
Stamp adds version information to a Bazel-built Go library.
License: MIT License
import “github.com/gebn/go-stamp”
.Summary()
.CodeSummary()
.Branch
.Commit
.Version // up to build info script to set this to whatever it likes - we are VCS agnostic. Git describe is the example.
.BuildSummary()
.User
.Hostname
.Time() // can the raw string representation be made private?
Such that it isn't identified as +incompatible
. Even though this is a Bazel project, it could still be used by people running go tool link -X
manually.
$(git remote get-url origin)
go version -m <1.18 binary>
, also available via debug.BuildInfo
so less ldflags required.
From a user perspective, it's annoying to have to write 3 import statements to use the library. Just have stamp.<Everything>
.
Ideally, people wanting to use the library would only have to write the go_repository
rule - the library would take care of adding necessary keys to the workspace status. Volatile build variables are provided for free by Bazel, however the STABLE_GIT_
ones must be provided by us - we effectively need a way to append to bazel-out/stable-status.txt
within Starlark.
This is a bit specific given go-stamp's involvement is retrieving a string, however it's a good use case.
As mentioned here.
Stamp uses a combination of workspace_status_command
and x_defs
to substitute values of Go var
s at link time. Unfortunately, there does not currently appear to be a way to add keys to the workspace status from Starlark, so this must be manually configured.
First, create an executable script with the following contents somewhere in your workspace, e.g. bin/workspace_status
(if you already have a workspace status script, you just need to add the three echo
lines to it):
...
Backwards-compatibility be damned.
This is more common, and allows integration with gopkg.in.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.