Skip to content
Node: semver.compare(a, b)github.com/sahilkhaire/gox/semver

Compare

Overview

Compare returns -1 if a < b, 0 if equal, 1 if a > b.

If you are coming from Node.js, the closest pattern is semver.compare(a, b).

Signature

go
func Compare(a, b string) int

Compare: Node.js · Standard Go · gox

js
semver.compare(a, b)
go
// github.com/Masterminds/semver/v3
go
import "github.com/sahilkhaire/gox/semver"

semver.Compare(a, b)

Example

go
import "github.com/sahilkhaire/gox/semver"

semver.Compare(a, b)

Tips

Import github.com/sahilkhaire/gox/semver and call Compare directly. See the comparison below for the standard library equivalent.

Standard library alternative

gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.

Back to semver package overview

MIT Licensed · Built for Node.js developers moving to Go