Skip to content

Latest commit

 

History

History
118 lines (91 loc) · 3.14 KB

README.md

File metadata and controls

118 lines (91 loc) · 3.14 KB

logo

All Contributors

GitHub release Go Report Card

curver is a simple way to display the version of a CUI tool made with go. curver was named as an abbreviation for current version.

Table of Contents

Installation

go get github.com/harakeishi/curver

Importing

import (
    "github.com/harakeishi/curver"
)

Documentation

Visit the docs on GoDoc

usage

If the value using ldflag is stored in the variable Version, that value will be displayed. Otherwise, it will display the build information embedded in the running binary.

use go build

// main.go
package main

import (
	"github.com/harakeishi/curver"
)

func main () {
    curver.EchoVersion()
}
$ go build -ldflags '-X github.com/harakeishi/curver.Version=v0.1.0' -o ./main

This will display the following format.

$ ./main
version: v0.1.0

If you want to embed the result of 'git tag', you can do the following

$ go build -ldflags "-X github.com/harakeishi/curver.Version=$(git describe --tags)" -o ./main

use goreleaser

If you are using goreleaser to do the release, do the following

builds:
  - eldflags:
      - -s -w -X github.com/harakeishi/curver.Version={{.Version}}

If you only want the version

The following will return the version as a string.

// main.go
package main

import (
	"github.com/harakeishi/curver"
)

func main () {
    version := curver.GetVersion()
}

License

Copyright (c) 2022 harakeishi Licensed under MIT

Contributors ✨

Thanks goes to these wonderful people (emoji key):


原 慧士

💻

This project follows the all-contributors specification. Contributions of any kind welcome!