encode

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package encode implements functions for encoding recordjar fields.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Boolean

func Boolean(b bool) []byte

Boolean returns the given boolean as a []byte containing either "TRUE" or "FALSE".

func Bytes

func Bytes(dataIn []byte) []byte

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

func DateTime(t time.Time) []byte

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

func Duration(d time.Duration) []byte

Duration returns the given time.Duration as a []byte. The byte slice will have the format "0h0m0.0s".

func Integer

func Integer(i int) []byte

Integer returns the passed integer value as a stringified []byte.

func Keyword

func Keyword(s string) []byte

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

func KeywordList(s []string) []byte

KeywordList returns the []string data as a whitespace separated, uppercased slice of bytes.

func PairList

func PairList(data [][2]string, delimeter string) (pairs []byte)

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".

func String

func String(s string) []byte

String returns the given string as a []byte.

Types

This section is empty.

Source Files

  • encoder.go

Jump to

Keyboard shortcuts

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