params

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2016 License: MIT Imports: 10 Imported by: 6

Documentation

Index

Constants

View Source
const (
	FS     int // 1
	MP         // 2
	AVAIL      // 3
	USEPCT     // 4
	USED       // 5
	TOTAL      // 6
)

Constants for DF sorting criterion.

View Source
const (
	PID  int // 1
	UID      // 2
	USER     // 3
	PRI      // 4
	NICE     // 5
	VIRT     // 6
	RES      // 7
	TIME     // 8
	NAME     // 9
)

Constants for PS sorting criterion.

Variables

View Source
var NumType = reflect.TypeOf(Num{})

Functions

func AddScheme added in v0.6.1

func AddScheme(input string) string

func ContainsPrefix

func ContainsPrefix(words []string, prefix string) (string, bool)

func Decode added in v0.6.1

func Decode(base *url.URL, input string, ignoreUnknownKeys bool,
	into interface {
		// pflag.Value
		setURL(url.URL)
	},
	urluser interface {
		UseURL(url.URL) error
	}) (map[string][]string, error)

Decode does url parsing and schema decoding.

func Pow2Less added in v0.6.1

func Pow2Less(v int) int

Pow2Less is internal.

func Pow2More added in v0.6.1

func Pow2More(v int) int

Pow2More is internal.

func TagsOk

func TagsOk(sf reflect.StructField) ([]string, bool)

Types

type ALink struct {
	Href       string
	Text       string
	ExtraClass string `json:",omitempty"`
}

func LessN added in v0.6.1

func LessN(p *Params, num *Num) (ALink, error)

LessN is in the func map.

func LinkN added in v0.6.1

func LinkN(p *Params, num *Num, absolute int, more bool) (ALink, error)

LinkN is internal.

func MoreN added in v0.6.1

func MoreN(p *Params, num *Num) (ALink, error)

MoreN is in the func map.

type FetchKey added in v0.6.1

type FetchKey struct {
	URL url.URL
	Schema

	// url tag not used til encoding with query.Values for normalization.
	Times int // `url:"times"`
}

FetchKey encloses an URL and has extra params.

type FetchKeys added in v0.6.1

type FetchKeys struct {
	Values    []FetchKey
	Fragments [][]string
	Default   FetchKey
}

func NewFetchKeys added in v0.6.1

func NewFetchKeys(defport int) *FetchKeys

func (*FetchKeys) Set added in v0.6.1

func (fkeys *FetchKeys) Set(input string) error

Set is a flag.Value method.

func (FetchKeys) String added in v0.6.1

func (fkeys FetchKeys) String() string

String is a flag.Value method.

func (FetchKeys) Type added in v0.6.1

func (fkeys FetchKeys) Type() string

Type is a pflag.Value method.

type Nlinks struct {
	More, Less ALink
}

type Num

type Num struct {
	Negative        bool
	Absolute        int
	DefaultNegative bool `json:"-"`
	DefaultAbsolute int  `json:"-"`
	Limit           int  `json:"-"`
	Alpha           bool `json:"-"`
	PositiveOnly    bool `json:"-"`
}

Num has no MarshalJSON.

func NumPrefix

func NumPrefix(words []string, prefix string) (Num, error)

func (Num) EncodeString

func (num Num) EncodeString() string

EncodeString returns string repr of Num. Templates render .Absolute value explicitly.

func (Num) EncodeValues

func (num Num) EncodeValues(key string, values *url.Values) error

func (*Num) UnmarshalText

func (num *Num) UnmarshalText(text []byte) error

type Params

type Params struct {
	Schema
	Defaults map[interface{}]Num `json:"-"`
}

func NewParams

func NewParams() *Params

NewParams constructs new Params.

func (*Params) Decode

func (p *Params) Decode(req *http.Request) error

func (Params) Encode

func (p Params) Encode() (string, error)

func (*Params) EncodeN

func (p *Params) EncodeN(num *Num, absolute int, setNegative *bool) (string, error)

func (*Params) EncodeT

func (p *Params) EncodeT(num *Num) (string, error)

func (*Params) MarshalJSON

func (p *Params) MarshalJSON() ([]byte, error)
func (p Params) Nlinks() map[string]Nlinks

func (*Params) ResetSchema

func (p *Params) ResetSchema()

func (*Params) SetDefaults

func (p *Params) SetDefaults(form url.Values)
func (p *Params) Tlinks() map[string]string
func (p *Params) Vlinks() map[string][]VLink

type RenamedConstError

type RenamedConstError string

RenamedConstError denotes an error.

func (RenamedConstError) Error

func (rc RenamedConstError) Error() string

type Schema

type Schema struct {
	// Still is here to be preserved for url encoding.
	// Not in use by Go code, but by js.
	Still Num `url:"still,posonly,default0"`

	CPUn Num `url:"cpun,default-2"`
	Dfn  Num `url:"dfn,default-2"`
	Ifn  Num `url:"ifn,default-2"`
	Lan  Num `url:"lan,default-3"`
	Memn Num `url:"memn,default-2"`
	Psn  Num `url:"psn,default-8"`

	Psk Num `url:"psk,default1,enumerate9"` // sort, default PID
	Dfk Num `url:"dfk,default1,enumerate6"` // sort, default FS
}
type VLink struct {
	CaretClass string
	LinkClass  string
	LinkHref   string
}
func Vlink(p *Params, num *Num, absolute int, text string) (VLink, error)

Vlink is in the func map.

Jump to

Keyboard shortcuts

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