Package buildinfo provides basic building blocks and instructions to easily add build and release information to your app.

Overview

buildinfo

Latest release Build status Go Report Card Documentation

Package buildinfo provides basic building blocks and instructions to easily add build and release information to your app. This is done by replacing variables in main during build with ldflags.

go get github.com/go-pogo/buildinfo
import "github.com/go-pogo/buildinfo"

Usage

Declare build info variables in your main package:

package main

// these values are changed via ldflags when building a new release
var (
    version = buildinfo.DummyVersion
    revision = buildinfo.DummyRevision
    date = buildinfo.DummyDate
)

func main() {
    bld := buildinfo.BuildInfo{
        Version:  version,
        Revision: revision,
        Date:     date,
    }
}

Build your Go project and include the following ldflags:

go build -ldflags=" \
  -X main.version=`$(git describe --tags)` \
  -X main.revision=`$(git rev-parse --short HEAD)` \
  -X main.date=`$(date +%FT%T%z`)" \
  main.go

Prometheus metric collector

When using a metrics scraper like Prometheus, it is often a good idea to make the build information of your app available. Below example shows just how easy it is to create and register a collector with the build information as constant labels.

prometheus.MustRegister(prometheus.NewGaugeFunc(
    prometheus.GaugeOpts{
        Namespace:   "myapp",
        Name:        buildinfo.MetricName,
        Help:        buildinfo.MetricHelp,
        ConstLabels: bld.Map(),
    },
    func() float64 { return 1 },
))

Documentation

Additional detailed documentation is available at pkg.go.dev

Created with

License

Copyright © 2020 Roel Schut. All rights reserved.

This project is governed by a BSD-style license that can be found in the LICENSE file.

Releases(v0.2.0)
Package fsm allows you to add finite-state machines to your Go code.

fsm Package fsm allows you to add finite-state machines to your Go code. States and Events are defined as int consts: const ( StateFoo fsm.State =

Cocoon Space 25 Jul 1, 2022
Works with HashiCorp HCL. Allows to append the input file with blocks and attributes from the template file

About hclmergetool Works with HashiCorp HCL. Allows to append the input file with blocks and attributes from the template file Installation Binary Rel

Max Fedorov 0 Feb 6, 2022
Geth client which picks the most profitable blocks to mine using a greedy algorithm

Greeden-Geth Greeden-Geth is a protocol-agnostic client which uses a greedy algorithm to pick the most profitable blocks to submit to the network out

Nathan 71 May 30, 2022
This repository provides various utilities to help you build your NFT collection!

Attention! A powerful computer may be required! About This repository provides various utilities to help you build your NFT collection: Generate image

Igor Savenko 4 May 18, 2022
Analyze the binary outputted by `go build` to get type information etc.

Analyze the binary outputted by go build to get type information etc.

Masaaki Goshima 15 May 20, 2022
Basic-api-with-go - A basic api with golang

I am creating my first API with GO. Install go get -u github.com/Yefhem/basic-ap

Yefhem 1 Jan 3, 2022
Go-basic-graphql - Basic implementation of GraphQL using Go

Go-basic-graphql - Basic implementation of GraphQL using Go

Luis Felipe Ribeiro 0 Jan 29, 2022
[Building]Use Go & Vue3 to build an easy blog

Go + Vue3 Study 环境安装 本地环境:Go 1.17 后端框架:Gin 注意Go在使用Go Module的话需要使用修改Go的代理 首先查看Go相关的环境变量 go env 修改Go代理 go env -w Go111MODULE=on go env -w GOPROXY=https:

Random_Chen 0 Jan 25, 2022
Help to release a project which especially has multiple git repositories

This project aims to help to release a project which especially has multiple git repositories. Installation Install it to a Kubernetes cluster. You ca

KubeSphere SIGs 9 Dec 21, 2021
Custom release of square/certstrap

certstrap A simple certificate manager written in Go, to bootstrap your own certificate authority and public key infrastructure. Adapted from etcd-ca.

Socheat Sok 0 Jan 18, 2022
Ghdl - A much more convenient way to download GitHub release binaries on the command line, works on Win & Unix-like systems

ghdl Memorize ghdl as github download ghdl is a fast and simple program (and als

beet 43 Apr 24, 2022
Hack this repo and add your name to the list above. Creativity and style encouraged in both endeavors.

Hack this repo and add your name to the list above. Creativity and style encouraged in both endeavors.

Danger 2 Oct 1, 2021
An easy way to add useful startup banners into your Go applications

Try browsing the code on Sourcegraph! Banner Add beautiful banners into your Go applications Table of Contents Motivation Usage API Command line flags

Claudemiro 398 Jun 28, 2022
It is a basic todo app which has CRUD operation using Buffalo and golang

It is a basic todo app which has CRUD operation using Buffalo and golang

null 0 Nov 1, 2021
James is your butler and helps you to create, build, debug, test and run your Go projects

go-james James is your butler and helps you to create, build, debug, test and run your Go projects. When you often create new apps using Go, it quickl

Pieter Claerhout 50 Mar 8, 2022
Tool to easily rename or move a bunch of files with a text editor of your choice

batch-rename With batch-rename you can utilize your favorite text editor to rename or move a bunch of files at once. It doesn't come with any features

David Vogel 0 Oct 13, 2021
Create one endpoint with add user functionality

hubuc-task Create one endpoint with add user functionality

Sachin Chavan 0 Nov 13, 2021
A basic golang package for demonstration purpose.

stringutils A basic golang package for demonstration purpose. Package currently contains only one function: func Reverse(s string) string Installation

Mert Kimyonşen 0 Nov 30, 2021
This example implements a basic example of how to create your own modules, and how to call them from other modules

This example implements a basic example of how to create your own modules, and how to call them from other modules. In addition, an example of how to do unit tests is developed.

null 1 Feb 1, 2022