rbxver

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 6 Imported by: 3

README

Go Reference

rbxver

The rbxver package handles parsing and formatting of Roblox version strings.

Documentation

Overview

The rbxver package handles parsing and formatting of Roblox version strings.

Index

Constants

This section is empty.

Variables

View Source
var ErrSyntax = errors.New("invalid syntax")

ErrSyntax indicates a syntax error while parsing a version string.

Functions

This section is empty.

Types

type Format

type Format int

Format determines how a version is parsed and formatted.

const (
	// Parse by guessing separator. Format as `0.0.0.0`.
	Any Format = iota
	// Parse with dot as separator. Format as `0.0.0.0`.
	Dot
	// Parse with comma as separator. Format as `0, 0, 0, 0`.
	Comma
)

type Version

type Version struct {
	Generation int // The first component.
	Version    int // The second component.
	Patch      int // The third component.
	Commit     int // The fourth component.

	// How the version was formatted, or how to format the version.
	Format Format
}

Version represents the version of a Roblox build. Versions can be compared for equality.

func Parse

func Parse(s string, f Format) Version

Parse parses s as a version string according to f. Returns the zero value if a version could not be parsed. A correctly parsed version will always have a non-zero Format.

Panics if f is not valid format.

func ParseBytes added in v0.3.0

func ParseBytes(b []byte, f Format) (v Version, n int, err error)

ParseBytes parses a version from b according to f.

n returns the number of bytes that were parsed from b. Trailing bytes that are not a part of the parsed version do not cause an error.

err will be ErrSyntax if the syntax is invalid, or io.ErrUnexpectedEOF if b does not have enough bytes to correctly parse the version. In either case, n will indicate where the error occurred.

Panics if f is not valid format.

func (Version) Compare added in v0.3.0

func (v Version) Compare(u Version) int

Compare returns -1 if v is semantically lower than u, 1 if v is semantically higher than u, and 0 if v is semantically equal to u.

func (Version) MarshalJSON added in v0.3.0

func (v Version) MarshalJSON() (b []byte, err error)

Implements json.Marshaler.

func (Version) String

func (v Version) String() string

String returns v as a string according to v.Format.

func (*Version) UnmarshalJSON added in v0.3.0

func (v *Version) UnmarshalJSON(b []byte) error

Implements json.Unmarshaler.

Jump to

Keyboard shortcuts

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