Skip to content

curver is an easy way to display the version of a CUI tool made with go. You can display the version either with go install or with built binaries. curver is named as an abbreviation of current version.

License

Notifications You must be signed in to change notification settings

harakeishi/curver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

All Contributors

GitHub release Go Report Card

curver is an easy way to display the version of a CUI tool made with go. You can display the version either with go install or with built binaries. curver is named as an abbreviation of 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

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:
  - ldflags:
      - -s -w -X github.com/harakeishi/curver.Version={{.Version}}

If you only want the version

The following will return the version as a string.

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):


原 慧士

💻

Akimo

📖

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

About

curver is an easy way to display the version of a CUI tool made with go. You can display the version either with go install or with built binaries. curver is named as an abbreviation of current version.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages