nut

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2012 License: BSD-2-Clause, BSD-3-Clause Imports: 12 Imported by: 0

README

nut Build Status

Nut is a tool to manage versioned Go source code packages, called "nuts".

Install it with go get:

go get -u github.com/AlekSi/nut/nut
nut help

Documentation

Overview

Package nut provides API for managing versioned Go source code packages, called "nuts".

Index

Constants

View Source
const (
	ExampleFullName = "Crazy Nutter"
	ExampleEmail    = "crazy.nutter@gonuts.io"
	SpecFileName    = "nut.json"
)

Variables

View Source
var VersionRegexp = regexp.MustCompile(`^(\d+).(\d+).(\d+)$`)

Current format for nut version.

Functions

func CheckPackage

func CheckPackage(pack *build.Package) (errors []string)

Check package for errors and return them.

Types

type Nut

type Nut struct {
	Spec
	build.Package
}

Describes nut – a Go package with associated meta-information.

func (*Nut) Check

func (nut *Nut) Check() (errors []string)

Check nut for errors and return them. Calls Spec.Check() and CheckPackage().

func (*Nut) FileName

func (nut *Nut) FileName() string

Returns canonical filename in format <name>-<version>.nut

func (*Nut) ReadFrom

func (nut *Nut) ReadFrom(Do, Not, Call bool) (do, not, call bool)

Code "Nut.ReadFrom()" will call Nut.Spec.ReadFrom(), while programmer likely wanted to call NutFile.ReadFrom(). This method (with weird incompatible signature) is defined to prevent this typical error.

type NutFile

type NutFile struct {
	Nut
	Reader *zip.Reader
}

Describes .nut file (a ZIP archive).

func (*NutFile) ReadFrom

func (nf *NutFile) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads nut from r until EOF. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned. Implements io.ReaderFrom.

type Person

type Person struct {
	FullName string
	Email    string `json:",omitempty"`
}

Describes nut author.

type Spec

type Spec struct {
	Version    Version
	Authors    []Person
	ExtraFiles []string `json:",omitempty"`
}

Describes part of nut meta-information, stored in file nut.json.

func (*Spec) Check

func (spec *Spec) Check() (errors []string)

Check spec for errors and return them.

func (*Spec) ReadFrom

func (spec *Spec) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads spec from r until EOF. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned. Implements io.ReaderFrom.

func (*Spec) WriteTo

func (spec *Spec) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes spec to w. The return value n is the number of bytes written. Any error encountered during the write is also returned. Implements io.WriterTo.

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

Describes nut version. See http://gonuts.io/-/doc/versioning for explanation of version specification.

func NewVersion

func NewVersion(version string) (v *Version, err error)

Parse and set version.

func (*Version) Less

func (left *Version) Less(right *Version) bool

Returns true if left < right, false otherwise.

func (*Version) MarshalJSON

func (v *Version) MarshalJSON() ([]byte, error)

Marshal to JSON.

func (Version) String

func (v Version) String() string

Return version as string in current format.

func (*Version) UnmarshalJSON

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

Unmarshal from JSON.

Directories

Path Synopsis
Package main implements 'nut' command.
Package main implements 'nut' command.

Jump to

Keyboard shortcuts

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