-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing "1.0" returns an error #16
Comments
Yes, that's intended, because of the semver spec: "1.0" is not valid semver version, but "1.0.0" is. |
Oh did you edit your question or did i read wrong? |
I added last sentence by editing the question (though before I saw your answer). I will have to fork your lib, because all the world uses versions like "v1.0" and thinks that it is semver format. E.g. gopkg.in supports both v3, v3.N, or v3.N.M format. |
Yap, you're right but i don't think simply accepting such "wrong" versions would be an option. Maybe i could introduce a |
I don't see anything on gopkg.in that claims anything about semantic versioning (as described by semver.org.) I think the part you referenced, @vmihailenco, is about "selectors."
|
Thanks for the link. I am not going to argue about semver spec. I just think that v1 (or v1.0) is not any worse than v1.0.0 and I want to accept it as user input. And I don't see any complications for parser to support such format. |
I still think this repo should remain strict semver spec only, but i also think it would be a nice addition to support parsing other version variants (v1.0, 1.0, ..) in a separate library and build proper semvers out of it. Anyone interested in contributing? |
@blang Would you be open to adding the |
I guess that depends on the extend of this function. I think there is a lot of room for convenience beginning at a starting 'v' and ending up trimming spaces, removing quotes etc. If it's a small function with a limited scope and useful for most usecases i would be glad if someone could make this happen. |
Great! Just submitted PR #19 |
Thank you |
Hi, I had same problem. Thank you for fixing this issue. Version "1.0" generally means latest version of "1.0.x", not "1.0.0". So, why don't you parse "1.0" as "1.0.INT_MAX"? |
@awakia That's a fair point! I think the reason I didn't go that route was that serializing versions was a concern for my use case, and Since we almost certainly don't want to change the underlying data structure, one way to go would be changing the // Version to string
func (v Version) String() string {
b := make([]byte, 0, 5)
b = strconv.AppendUint(b, v.Major, 10)
if v.Minor != math.MaxUint64 {
b = append(b, '.')
b = strconv.AppendUint(b, v.Minor, 10)
}
if v.Patch != math.MaxUint64 {
b = append(b, '.')
b = strconv.AppendUint(b, v.Patch, 10)
}
// ... This would maintain readability of the stringified versions. @blang what do you think? |
I think |
Did you consider allowing versions like "1.0"? I personally did not know that semver requires X.Y.Z format.
The text was updated successfully, but these errors were encountered: