nut

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2013 License: BSD-2-Clause, BSD-3-Clause Imports: 14 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/...
touch ~/.nut.json
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 VendorRegexp = regexp.MustCompile(`^[0-9a-z][0-9a-z_-]*$`)
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. It embeds Spec and build.Package to provide easy access to properties: Nut.Name instead of Nut.Package.Name, Nut.Version instead of Nut.Spec.Version.

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) FilePath added in v0.3.0

func (nut *Nut) FilePath(prefix string) string

Returns canonical filepath in format <prefix>/<vendor>/<name>-<version>.nut (with "\" instead of "/" on Windows).

func (*Nut) ImportPath added in v0.3.0

func (nut *Nut) ImportPath(prefix string) string

Returns canonical import path in format <prefix>/<vendor>/<name>

func (*Nut) ReadFrom

func (nut *Nut) ReadFrom(dir string) (err error)

Read nut from directory: package from <dir> and spec from <dir>/<SpecFileName>.

type NutFile

type NutFile struct {
	Nut
	Reader *zip.Reader
}

Describes .nut file (a ZIP archive).

func (*NutFile) ReadFile added in v0.3.0

func (nf *NutFile) ReadFile(fileName string) (err error)

Reads nut from specified file.

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
	Vendor     string
	Authors    []Person
	ExtraFiles []string
	Homepage   string
}

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

func (*Spec) Check

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

Checks spec for errors and return them.

func (*Spec) ReadFile added in v0.3.0

func (spec *Spec) ReadFile(fileName string) (err error)

Reads spec from specified file.

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 (NOT A PUBLIC API).
Package main implements 'nut' command (NOT A PUBLIC API).

Jump to

Keyboard shortcuts

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