Documentation
¶
Overview ¶
Package encode implements functions for encoding recordjar fields.
Index ¶
- func Boolean(b bool) []byte
- func Bytes(dataIn []byte) []byte
- func DateTime(t time.Time) []byte
- func Duration(d time.Duration) []byte
- func Integer(i int) []byte
- func Keyword(s string) []byte
- func KeywordList(s []string) []byte
- func PairList(data [][2]string, delimeter string) (pairs []byte)
- func String(s string) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Boolean ¶
Boolean returns the given boolean as a []byte containing either "TRUE" or "FALSE".
func Bytes ¶
Bytes returns a copy of the passed []byte. Important so we don't accidentally pin a larger backing array in memory via the slice.
func DateTime ¶
Duration returns the given time.Duration as a []byte. The byte slice will be formatted according to RFC1123. For example "Mon, 02 Jan 2006 15:04:05 MST".
func Duration ¶
Duration returns the given time.Duration as a []byte. The byte slice will have the format "0h0m0.0s".
func Integer ¶
Integer returns the passed integer value as a stringified []byte.
func Keyword ¶
Keyword returns the passed string as an uppercased []byte. This is helpful for keeping IDs and references consistent and independent of how they appear in e.g. data files.
func KeywordList ¶
KeywordList returns the []string data as a whitespace separated, uppercased slice of bytes.
func PairList ¶
PairList returns the passed slice of string pairs as an uppercased []byte. Each pair of strings is separated with the given delimiter. All of the string pairs are then concatenated together separated by whitespace.
exits := [][2]string{
[2]string{"E", "L3"},
[2]string{"SE", "L4"},
[2]string{"S", "L2"},
}
data := PairList(exits, "→")
Results in data being a byte slice containing "E→L3 SE→L4 S→L2".
Types ¶
This section is empty.
Source Files
¶
- encoder.go