ikawaha/kagome

Version display support

KEINOS opened this issue · 4 comments

[Feature request]

Not a strong request though, it would be nice if I can check the current local Kagome's version.

$ kagome -version
Kagome v1.7.3 (build 9f4fc8a)

Kagome works great! on:

  • macOS HighSierra (OS X 10.13.6, build 17G65)
  • Kagome : v1.7.3
  • $ go version : go version go1.10.3 darwin/amd64

A good idea! It seems to be possible if a version is embedded in the code, but it may conflict with the tag version specified in github. (Maybe I will make a mistake. :p )

Is there a way to automatically embed github tag (or commit number) at go get ?

Thank you!

I'm not sure exactly how to in Golang but I can get the version tag localy like so:

$ cd $GOPATH/src/github.com/ikawaha/kagome && git tag --points-at
v1.7.3
$ cd $GOPATH/src/github.com/ikawaha/kagome && git describe
v0.1.0-355-g9f4fc8a

So, adding the version info while building process would be the realistic approach than hard coding every time.

As a info, according to the document at Qiita, it seems like adding some codes like below and build it with -ld option will may do the thing.

(Sorry that I'm not a gopher nor golanger guy... m(_ _;)m )

package main

import (
    "flag"
    "fmt"
)

var version string
var show_version = flag.Bool("version", false, "show version")

func main() {
    flag.Parse()
    if *show_version {
        fmt.Printf("version: %s\n", version)
        return
    }
    // ... snip ...
}
go build -ldflags "-X main.version $(git describe)" main.go

Hope this helps for something.
And thanks for providing us the cool "Kagome" ! I ❤️IT!

As of v1.10.0 (9eda13e), the version print feature is implemented! 🎉

So, I think it is time to close this issue!

And thanks to @ikawaha for the effort of refactoring (a lot) of my newbie coding and made it the way it has to be!

Many thanks @KEINOS !