Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into leading-zero
Browse files Browse the repository at this point in the history
  • Loading branch information
matfax authored Jan 12, 2019
2 parents 019664c + 8974d02 commit d58a79c
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 80 deletions.
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

# Created by https://www.gitignore.io/api/go,linux,windows
# Edit at https://www.gitignore.io/?templates=go,linux,windows

### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

### Go Patch ###
/vendor/
/Godeps/

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/go,linux,windows
1 change: 0 additions & 1 deletion .gx/lastpubver

This file was deleted.

21 changes: 1 addition & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
language: go
matrix:
include:
- go: 1.4.x
- go: 1.5.x
- go: 1.6.x
- go: 1.7.x
- go: 1.8.x
- go: 1.9.x
- go: 1.10.x
- go: tip
allow_failures:
- go: tip
install:
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
script:
- echo "Test and track coverage" ; $HOME/gopath/bin/goveralls -package "." -service=travis-ci
-repotoken $COVERALLS_TOKEN
- echo "Build examples" ; cd examples && go build
- echo "Check if gofmt'd" ; diff -u <(echo -n) <(gofmt -d -s .)
env:
global:
secure: HroGEAUQpVq9zX1b1VIkraLiywhGbzvNnTZq2TMxgK7JHP8xqNplAeF1izrR2i4QLL9nsY+9WtYss4QuPvEtZcVHUobw6XnL6radF7jS1LgfYZ9Y7oF+zogZ2I5QUMRLGA7rcxQ05s7mKq3XZQfeqaNts4bms/eZRefWuaFZbkw=
- go: 1.11.x
52 changes: 16 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
semver for golang [![Build Status](https://travis-ci.org/blang/semver.svg?branch=master)](https://travis-ci.org/blang/semver) [![GoDoc](https://godoc.org/github.com/blang/semver?status.svg)](https://godoc.org/github.com/blang/semver) [![Coverage Status](https://img.shields.io/coveralls/blang/semver.svg)](https://coveralls.io/r/blang/semver?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/blang/semver)](https://goreportcard.com/report/github.com/blang/semver)
======
# semver

[![Build Status](https://travis-ci.com/gofunky/semver.svg?branch=master)](https://travis-ci.com/gofunky/semver)
[![GoDoc](https://godoc.org/github.com/gofunky/semver?status.svg)](https://godoc.org/github.com/gofunky/semver)
[![Go Report Card](https://goreportcard.com/badge/github.com/gofunky/semver)](https://goreportcard.com/report/github.com/gofunky/semver)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ea2478d087b94d7f920a607d73c5d8a0)](https://www.codacy.com/app/gofunky/semver?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=gofunky/semver&amp;utm_campaign=Badge_Grade)
[![GitHub License](https://img.shields.io/github/license/gofunky/semver.svg)](https://github.com/gofunky/semver/blob/master/LICENSE)
[![GitHub last commit](https://img.shields.io/github/last-commit/gofunky/semver.svg)](https://github.com/gofunky/semver/commits/master)

semver is a [Semantic Versioning](http://semver.org/) library written in golang. It fully covers spec version `2.0.0`.

Usage
-----
## Usage

```bash
$ go get github.com/blang/semver
```
Note: Always vendor your dependencies or fix on a specific version tag.

```go
import github.com/blang/semver
v1, err := semver.Make("1.0.0-beta")
v2, err := semver.Make("2.0.0-beta")
v1.Compare(v2)
```

Also check the [GoDocs](http://godoc.org/github.com/blang/semver).
Also check the [GoDocs](http://godoc.org/github.com/gofunky/semver).

Why should I use this lib?
-----
## Why should I use this lib?

- Fully spec compatible
- No reflection
Expand All @@ -33,8 +37,7 @@ Why should I use this lib?
- Many features, see below


Features
-----
## Features

- Parsing and validation at all levels
- Comparator-like comparisons
Expand All @@ -46,8 +49,7 @@ Features
- database/sql compatible (sql.Scanner/Valuer)
- encoding/json compatible (json.Marshaler/Unmarshaler)

Ranges
------
## Ranges

A `Range` is a set of conditions which specify which versions satisfy the range.

Expand Down Expand Up @@ -90,14 +92,11 @@ if range(v) {
```

Example
-----
## Example

Have a look at full examples in [examples/main.go](examples/main.go)

```go
import github.com/blang/semver

v, err := semver.Make("0.0.1-alpha.preview+123.github")
fmt.Printf("Major: %d\n", v.Major)
fmt.Printf("Minor: %d\n", v.Minor)
Expand Down Expand Up @@ -149,8 +148,7 @@ if err != nil {
```


Benchmarks
-----
## Benchmarks

BenchmarkParseSimple-4 5000000 390 ns/op 48 B/op 1 allocs/op
BenchmarkParseComplex-4 1000000 1813 ns/op 256 B/op 7 allocs/op
Expand All @@ -174,21 +172,3 @@ Benchmarks
BenchmarkRangeMatchComplex-4 10000000 153 ns/op 0 B/op 0 allocs/op

See benchmark cases at [semver_test.go](semver_test.go)


Motivation
-----

I simply couldn't find any lib supporting the full spec. Others were just wrong or used reflection and regex which i don't like.


Contribution
-----

Feel free to make a pull request. For bigger changes create a issue first to discuss about it.


License
-----

See [LICENSE](LICENSE) file.
3 changes: 2 additions & 1 deletion examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"

"github.com/blang/semver"
)

Expand Down Expand Up @@ -33,7 +34,7 @@ func main() {
}

// Make == Parse (Value), New for Pointer
v001, err := semver.Make("0.0.1")
v001, _ := semver.Make("0.0.1")

fmt.Println("\nUse Version.Compare for comparisons (-1, 0, 1):")
fmt.Printf("%q is greater than %q: Compare == %d\n", v001, v, v001.Compare(v))
Expand Down
17 changes: 0 additions & 17 deletions package.json

This file was deleted.

8 changes: 4 additions & 4 deletions semver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func BenchmarkStringSimple(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
v.String()
_ = v.String()
}
}

Expand All @@ -378,7 +378,7 @@ func BenchmarkStringLarger(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
v.String()
_ = v.String()
}
}

Expand All @@ -388,7 +388,7 @@ func BenchmarkStringComplex(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
v.String()
_ = v.String()
}
}

Expand All @@ -397,7 +397,7 @@ func BenchmarkStringAverage(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
formatTests[n%l].v.String()
_ = formatTests[n%l].v.String()
}
}

Expand Down
2 changes: 1 addition & 1 deletion sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (v *Version) Scan(src interface{}) (err error) {
case []byte:
str = string(src)
default:
return fmt.Errorf("Version.Scan: cannot convert %T to string.", src)
return fmt.Errorf("version.Scan: cannot convert %T to string", src)
}

if t, err := Parse(str); err == nil {
Expand Down

0 comments on commit d58a79c

Please sign in to comment.