mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.78k stars 279 forks source link

Application version support #381

Closed JiriSko closed 3 years ago

JiriSko commented 4 years ago

Hi, thanks for this great tool.

Would be possible to add application version support in standard way? I mean to add --version CLI option which shows revive version.

mgechev commented 4 years ago

Maybe revive -help can show the current SHA. In general, I am hoping us to not have to stick to a particular version. Instead, revive is supposed to be an "evergreen" tool that anyone can use the last version of. That's one of the reasons I was originally against introducing semver to the project.

JiriSko commented 4 years ago

That would be helpful. I just want to see in my pipeline which version I'm using and this would be enough.

nano-adhara commented 4 years ago

+1 golint doesnt provide any information and i was hoping for this tool to provide such information on top of golint

nvuillam commented 3 years ago

@mgechev I also need --version for Mega-Linter , please :)

Clivern commented 3 years ago

I can do this if this PR (#503) got approved/released, since goreleaser already provide these info from git as ldflags during build. it is just a matter of adding the following vars to main.go and create a command to return them.

var (
    version = "dev"
    commit  = "none"
    date    = "unknown"
    builtBy = "unknown"
)

// in the --version or --help command handler
fmt.Sprintf(
    `Current revive Version %v Commit %v, Built @%v By %v.`,
    version,
    commit,
    date,
    builtBy,
),

if you're building revive manually, then it is your responsibility to provide the version during build (eg. go build -v -ldflags="-X 'main.version=v1.0.0' -X 'main.commit=46f65914e3b26f7044ffe6842ecce10b58e2c2aa' -X 'main.date=@2021-03-21T21:37:16Z' -X 'main.builtBy=clivern'") or it will be unknown, same goes for commit, date, builtBy

chavacava commented 3 years ago

@Clivern #503 is merged ;)

Clivern commented 3 years ago

yeah, i will take care of this request then @chavacava