Help us shape the future of Go! Take the 2026 Go Developer Survey

zver

package module
v0.0.0-...-95a6fb8 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

zver

版本解析模块

获取

go get -u -v github.com/zlyuancn/zver

3级版本实例

package main

import (
    "fmt"
    "github.com/zlyuancn/zver"
)

func main() {
    v1 := new(zver.V3)
    if err := v1.Parser("3.4.2", "."); err != nil {
        panic(err)
    }

    fmt.Println(v1)
    fmt.Println(v1.ToText("_"))
    fmt.Println(v1.ToTextHasPrefix(".", "v"))

    v2 := new(zver.V3)
    if err := v2.ParserHasPrefix("v3.4.3", ".", "v"); err != nil {
        panic(err)
    }

    fmt.Println(v1, ">", v2, ":", v1.Gt(v2))
    fmt.Println(v1, ">=", v2, ":", v1.Gte(v2))
    fmt.Println(v1, "<", v2, ":", v1.Lt(v2))
    fmt.Println(v1, "<=", v2, ":", v1.Lte(v2))
    fmt.Println(v1, "=", v2, ":", v1.Eq(v2))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitToUint

func SplitToUint(text, sep string) ([]uint, error)

将文本切割并转换为uint类型

Types

type V3

type V3 struct {
	Main    uint // 主版本, 最大为4位数
	Minor   uint // 次版本, 最大为4位数
	Mini    uint // 小版本, 最大为6位数
	Numeric uint // 版本数值
}

func NewV3

func NewV3(version string, sep ...string) (*V3, error)

func NewV3WithPrefix

func NewV3WithPrefix(version, prefix string, sep ...string) (*V3, error)

func (*V3) Eq

func (v3 *V3) Eq(v *V3) bool

判断两个版本是否相等

func (*V3) Gt

func (v3 *V3) Gt(v *V3) bool

判断当前版本大于传入的版本

func (*V3) Gte

func (v3 *V3) Gte(v *V3) bool

判断当前版本大于或等于传入的版本

func (*V3) Lt

func (v3 *V3) Lt(v *V3) bool

判断当前版本小于传入的版本

func (*V3) Lte

func (v3 *V3) Lte(v *V3) bool

判断当前版本小于或等于传入的版本

func (*V3) Ne

func (v3 *V3) Ne(v *V3) bool

判断两个版本是否不相等

func (*V3) Parser

func (v3 *V3) Parser(version, sep string) error

从版本文本中解析

func (*V3) ParserHasPrefix

func (v3 *V3) ParserHasPrefix(version, sep, prefix string) error

从有前缀的版本文本中解析

func (*V3) String

func (v3 *V3) String() string

转为默认格式的版本文本

func (*V3) ToText

func (v3 *V3) ToText(sep string) string

转为版本文本

func (*V3) ToTextHasPrefix

func (v3 *V3) ToTextHasPrefix(sep, prefix string) string

转为有前缀的版本文本

Jump to

Keyboard shortcuts

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