binenv icon indicating copy to clipboard operation
binenv copied to clipboard

string -> int type conversion loses `0` prefix in numbers (was: How add app when release with date ?)

Open patsevanton opened this issue 4 years ago • 5 comments

Hello! Thanks for binenv. I try add app https://github.com/deref/exo to binenv. But app when release with date

patsevanton avatar Aug 03 '21 05:08 patsevanton

Hey @patsevanton

It should be the same as usual. The culprit here is that version contains a v. So to handle this, you could use {{ .VersionMajor }}, {{ .VersionMinor }} and {{ .VersionPatch }}.

See bomberman for an example.

Good luck & tell us how it goes.

leucos avatar Aug 03 '21 05:08 leucos

Thanks. But it another quiestion - https://github.com/deref/exo/releases/download/v2021.07.30/exo-2021.07.30-linux-amd64

Download link have date.

patsevanton avatar Aug 03 '21 07:08 patsevanton

This almost works:

fetch:
  url: https://github.com/deref/exo/releases/download/v{{ .VersionMajor }}.{{ .VersionMinor }}.{{ .VersionPatch }}/exo-{{ .VersionMajor }}.{{ .VersionMinor }}.{{ .VersionPatch }}-{{ .OS }}-{{ .Arch }}

However, since there is some type conversion from string to int somewhere, the generated link is

https://github.com/deref/exo/releases/download/v2021.7.30/exo-2021.7.30-linux-amd64

instead of

https://github.com/deref/exo/releases/download/v2021.07.30/exo-2021.07.30-linux-amd64

So I guess we're stuck for now on this one.

leucos avatar Aug 03 '21 07:08 leucos

Luckily there is a 2021.10.12 version :D

leucos avatar Oct 16 '21 09:10 leucos

The "issue" comes from the upstream library https://github.com/hashicorp/go-version/blob/master/version.go#L69 See also https://github.com/hashicorp/go-version/issues/86

leucos avatar Oct 16 '21 09:10 leucos