semantic

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2019 License: BSD-3-Clause Imports: 5 Imported by: 2

README

semantic

Create and Parse SemVer 2.0 tags in Go

Go Report Card Build Status GoDoc NetflixOSS Lifecycle GitHub

Project Overview

Module gophers.dev/pkgs/semantic can be used to parse / create / manipulate SemVer 2.0 tags.

Getting Started

The semantic module can be installed by running

$ go get gophers.dev/pkgs/semantic
Example Create Tag
// create a tag for "v1.2.3"
tag := semantic.New(1, 2, 3)

// create a pre-release tag with -rc1
tag := semantic.New2(1, 2, 3, "rc1")

// create a tag with build-metadata
tag := semantic.New4(1, 2, 3, "exp.sha.5114f86")

// create a pre-release tag with build-metadata
tag := semantic.New3(1, 2, 3, "rc1", "exp.sha.5114f86")
Example Parse Tag
tag, ok := semantic.Parse("v1.2.3-rc1+linux")
Example Sort Tags
tags := []semantic.Tag{
    semantic.New2(1, 1, 1, "alpha.1"),
    semantic.New(1, 1, 1),
    semantic.New2(1, 1, 1, "alpha"),
    semantic.New2(1, 1, 1, "beta.11"),
    semantic.New2(1, 1, 1, "beta.2"),
    semantic.New2(1, 1, 1, "rc.1"),
    semantic.New2(1, 1, 1, "beta"),
    semantic.New2(1, 1, 1, "alpha.beta"),
}
sort.Sort(semantic.BySemver(tags))

Contributing

The gophers.dev/pkgs/semantic module is always improving with new features and error corrections. For contributing bug fixes and new features please file an issue.

License

The gophers.dev/pkgs/semantic module is open source under the BSD-3-Clause license.

Documentation

Overview

Package semantic provides utilities for parsing and creating semver2.0 tags.

For more information, see https://semver.org/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BySemver

type BySemver []Tag

func (BySemver) Len

func (tags BySemver) Len() int

func (BySemver) Less

func (tags BySemver) Less(x, y int) bool

func (BySemver) Swap

func (tags BySemver) Swap(x, y int)

type Tag

type Tag struct {
	Major         int
	Minor         int
	Patch         int
	PreRelease    string
	BuildMetadata string
}

func New

func New(major, minor, patch int) Tag

New creates a new Tag with the most basic amount of information, which includes the major, minor, and patch version levels.

Examples of a basic tag:

v1.0.0
v3.20.100

func New2

func New2(major, minor, patch int, preRelease string) Tag

New2 creates a new Tag with the basic version information, plus an additional associated pre-release suffix.

The pre-release information is appended to the end of a version string, denoted with a '-' prefix.

Examples of a tag with "pre-release" information:

v1.0.0-alpha
v1.0.0-rc1

func New3 added in v0.1.0

func New3(major, minor, patch int, preRelease, buildMetadata string) Tag

New3 creates a new Tag with the basic version information, plus an additional associated pre-release suffix plus an additional build-metadata suffix.

The pre-release information is appended to the end of a version string, but before the build-metadata, denoted with a '-' prefix.

The build-metadata information is appended to the end of a version string, denoted with a '+' prefix.

Examples of a tag with "pre-release" and "build-metadata" information:

v1.0.0-beta+exp.sha.5114f85
v1.0.0-rc1+20130313144700
1.0.0-alpha+001

func New4 added in v0.2.0

func New4(major, minor, patch int, buildMetadata string) Tag

New4 creates a new Tag with basic version information, plus an additional associated build-metadata suffix.

The build-metadata information is appended to the end of a version string, denoted with a '+' prefix.

Examples of a tag with "build-metadata" information:

v1.0.0+exp.sha.5114f85
v1.0.0+20130313144700

func Parse

func Parse(s string) (Tag, bool)

func (Tag) Base

func (t Tag) Base() Tag

func (Tag) IsBase

func (t Tag) IsBase() bool

func (Tag) Less

func (t Tag) Less(o Tag) bool

func (Tag) String

func (t Tag) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL