version

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b Version) int

Compare 比较两个 Version 的大小.

返回 -1 表示 a < b
返回 0  表示 a == b
返回 +1 表示 a > b

Types

type Version

type Version struct {
	Major, Minor, Patch int
}

Version 表示一个 major.minor.patch 格式的版本号.

func New

func New(major, minor, patch int) Version

func Parse

func Parse(str string) (v Version, ok bool)

Parse 解析 x, x.y, x.y.z 格式的字符串到 Version 对象, 如果成功 ok 为 true, 否则为 false.

func (Version) Compare

func (v Version) Compare(v2 Version) int

Compare 比较 v 和 v2 的大小.

返回 -1 表示 v < v2
返回 0  表示 v == v2
返回 +1 表示 v > v2

func (Version) String

func (v Version) String() string

String 将 Version 格式化成 major.minor.patch 的格式.

Jump to

Keyboard shortcuts

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