version

package
v0.0.0-...-64d2d59 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package version contains routines to parse Debian package version numbers.

Example:

package main

import (
	"fmt"
	"os"

	"maze.io/dpkg.v1/version"
)

func main() {
	if len(os.Args) != 3 {
		fmt.Fprintf(os.Stderr, "%s a b\n", os.Args[0])
		os.Exit(1)
	}
	var a, b version.Version
	var err error
	if a, err = version.New(os.Args[1]); err != nil {
		fmt.Fprintf(os.Stderr, "%s: %v\n", os.Args[1], err)
		os.Exit(1)
	}
	if b, err = version.New(os.Args[2]); err != nil {
		fmt.Fprintf(os.Stderr, "%s: %v\n", os.Args[2], err)
		os.Exit(1)
	}

	r := version.Compare(a, b)
	switch {
	case r < 0:
		fmt.Printf("%s is older than %s", a, b)
	case r > 0:
		fmt.Printf("%s is more recent than %s", a, b)
	default:
		fmt.Println("versions are equal")
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b Version) int

Compare two package versions.

func Sort

func Sort(versions []string)

Types

type Version

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

Version is a Debian package version.

func New

func New(s string) (v Version, err error)

New parses a version string.

func (Version) Compare

func (v Version) Compare(other Version) int

Compare two version numbers.

func (Version) Epoch

func (v Version) Epoch() uint64

Epoch for the version, defaults to 0 if not set.

func (Version) IsEmpty

func (v Version) IsEmpty() bool

IsEmpty checks if there is no version information set.

func (Version) String

func (v Version) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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