Skip to content

golistic/shieldbadger

Repository files navigation

shieldbadger — Uses shields.io to produce badges

Go: 1.23

Copyright (c) 2023, 2025, Geert JM Vanderkelen

The shieldbadger Go package uses the Shields.io service to produce badges which are locally written. This allows projects to have the badges stored and present anywhere they want without needing an internet connection.

Installation

go install github.com/golistic/shieldbadger/cmd/shieldbadger@latest

The shieldbadger command is installed in the bin folder of your Go installation. Use the PATH environment variable to add this folder to your PATH. Or, install it somewhere else using the -o flag.

Usage

Create a configuration file in your project, for example, _badges/badges.json:

{
  "style": "flat-square",
  "urlShieldsIO": "https://img.shields.io/static/v1",
  "destFolder": "_badges",
  "badges": [
    {
      "name": "go-version",
      "label": "GO",
      "messageFunc": "go.mod.version",
      "color": "#00ADD8"
    }
  ]
}

The above configuration will produce a badge named go-version.svg in the _badges folder. The badge will be a flat square with the label GO and the message will be the version of the Go module in the go.mod file.

The messageFunc can be any function that returns a string. The go.mod.version function is provided by the shieldbadger package.

Run the shieldbadger command (see installation above):

shieldbadger -config _badges/badges.json

The badge will be written to the _badges folder.

Add the badge to your README.md, for example:

<div>
  <img alt="Go: 1.23" src="_badges/go-version.svg">
</div>

License

Distributed under the MIT license. See LICENSE.md for more information.

About

Uses shields.io to produce badges and store locally

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages