versioning

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Overview

Package versioning is a version comparison tool that conforms to semantic version 2.0.0

Copyright 2022 AndeyaLee Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b string, compareMetadata func(aMeta, bMeta string) int) (int, error)

Compare compares 'a' and 'b'. The result will be 0 if a==b, -1 if a < b, and +1 if a > b. If compareMetadata==nil, will not compare metadata.

Types

type SemVer

type SemVer struct {
	// contains filtered or unexported fields
}

SemVer semantic version object via https://semver.org/

func Create

func Create(major, minor, patch uint32, metadata string) *SemVer

Create creates a semantic version object.

func Parse

func Parse(semVer string) (*SemVer, error)

Parse parses the semantic version string to object. NOTE: If metadata part exists, the separator must not be a number.

func (*SemVer) Compare

func (s *SemVer) Compare(semVer *SemVer, compareMetadata func(sMeta, semVerMeta string) int) int

Compare compares whether 's' and 'semVer'. The result will be 0 if s==semVer, -1 if s < semVer, and +1 if s > semVer. If compareMetadata==nil, will not compare metadata.

func (*SemVer) Major

func (s *SemVer) Major() string

Major returns the version major.

func (*SemVer) Metadata

func (s *SemVer) Metadata() string

Metadata returns the version metadata. Examples:

1.0.0-alpha+001 => -alpha+001
1.0.0+20130313144700 => +20130313144700
1.0.0-beta+exp.sha.5114f85 => -beta+exp.sha.5114f85
1.0.0rc => rc

func (*SemVer) Minor

func (s *SemVer) Minor() string

Minor returns the version minor.

func (*SemVer) Patch

func (s *SemVer) Patch() string

Patch returns the version patch.

func (*SemVer) String

func (s *SemVer) String() string

String returns the version string.

Jump to

Keyboard shortcuts

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