coreos / go-semver Goto Github PK
View Code? Open in Web Editor NEWsemver library in Go
Home Page: http://semver.org
License: Apache License 2.0
semver library in Go
Home Page: http://semver.org
License: Apache License 2.0
Thanks for the awesome library! One thing I noticed that's probably intentional is that Version.Equals returns false if the patch and minor versions are different but major is equal.
Equals might be the wrong method since it might imply strict equality, but maybe there should be another method that compares versions more closely to the semver spec? The first thing that came to mind is BackwardsCompatible or maybe Compatible if that's too wordy.
Thanks for your time!
As you implemented Unmashler
interface, but didn't implement Marshler
interface for yaml.
So it's impossible to unmarshal it from yaml as it would fail with error: cannot unmarshal !!map into string
the solution would be to add
func (v Version) MarshalYAML() (interface{}, error) {
return v.String(), nil
}
In unit test TestBumpMajor
(and in other places), the test data being used in Line 178 is:
1.0.0+build.1-alpha.1
Prerelease should come first and must have a prefix of -
Metadata should come in the end and must have a prefix of +
.
This test data is the other way around.
Let's see what happens when we use this test data in an example:
package main
import "fmt"
import "github.com/coreos/go-semver/semver"
func main() {
v := semver.New("1.0.0+build.1-alpha.1")
fmt.Printf("PreRelease: %s\n", v.PreRelease)
fmt.Printf("Metadata: %s\n", v.Metadata)
}
And the output is:
PreRelease:
Metadata: build.1-alpha.1
Therefore the testing in Line 180 is not really effective, considering that PreRelease was ""
to begin with.
I propose that the test data be changed to:
1.0.0-alpha.1+build.1
If you agree, let me know and I will work on a pull request.
Please see:
Steps to reproduce:
func TestSemVer(t *testing.T) {
actual, err := semver.NewVersion("17.06.0-ce")
if err != nil {
t.Fatal(err.Error())
}
wanted, err := semver.NewVersion("17.06.0")
if err != nil {
t.Fatal(err.Error())
}
if actual.Compare(*wanted) < 0 {
t.Fatal("not good")
}
}
For usability, it would be nice if one could pass a *semver.Version
to LessThan()
, Equal()
, and Compare()
. Is there something preventing this? And why are those methods defined on a value receiver instead of a pointer receiver?
The helper functions does not seem to provide any valuable API functionality. It should be private IMO.
https://github.com/coreos/go-semver/blob/master/semver/semver.go#L63
We are importing this into rkt, hence it would be nice/important to have released versions.
panic: strconv.ParseInt: parsing "v0": invalid syntax
goroutine 1 [running]:
github.com/coreos/go-semver/semver.Must(...)
I have the following in my code, which GoLand complains about: semver "github.com/coreos/go-semver"
Is it because the go.mod is prior to go 1.11?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.