Git Product home page Git Product logo

buildinfo's Introduction

buildinfo

Golang utility to generate build information suitable for embedding in code.

Applications usually expose their version information in one way or another. Up until this point, in the context of Golang, this information was embedded into the compiled artifact via linker flags during building. The actual information was calculated via a series of (shell-) commands. Since all of this requires orchestration, this was usually done using some kind of build system (Make, Bazel, ...)

buildinfo aims to remove all that cruft, by collecting and exposing the build information in a single call.

Despite the name, it has actually no relation and very little similarity to debug.Buildinfo, which is available since Golang 1.18.

Usage

Typically buildinfo is used as Golang generator.

It can create boilerplate code for setting up the required code on its own:

buildinfo --generate golang-embed --filename version.go

This will create a file named version.go in the current working directory.

To prevent muddying your repository, it is recommended to add the generator output to the VCS ignore list. To allow your project to run and compile in a development setting, where version information is not of the utmost importance, a minimalistic version should be kept under version control nontheless. To be more precise, create two files in the directory next to your code with the go:generate instruction:

.gitignore

buildinfo.json

buildinfo.json

{}

Building

buildinfo (the library) does not require any pre-processing. buildinfo (the tool) lives in the tools subdirectory. Generated files are shipped with the source code and can be recreated using the respective utilities.

Man pages

cd ./tools
go install github.com/mmarkdown/mmark/v2@latest
go generate ./man

Build information

cd ./tools
go install github.com/UiP9AV6Y/buildinfo/tools/cmd/buildinfo@latest
go generate ./version

buildinfo

cd ./tools
go build -o buildinfo ./cmd/buildinfo

Example

buildinfo dogfeeds its own product in ./tools/version/version.go.

Alternatives

License

BSD 4-Clause, see LICENSE.

buildinfo's People

Contributors

uip9av6y avatar

Stargazers

ekis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.