Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnexpectedClose = errors.New("Got unexpected close token") ErrMissingClose = errors.New("Did not receive a close token") ErrBadKeyType = errors.New("Lich dict key must be of type data") )
Errors introduced during decoding
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array []Element
Example ¶
package main
import (
"fmt"
"github.com/carlmjohnson/lich"
)
func main() {
array := lich.Array{lich.DataString("apple"), lich.DataString("banana"), lich.DataString("orange")}
fmt.Println(array)
}
Output: 26[5<apple>6<banana>6<orange>]
func ArrayFromStrings ¶
Example ¶
package main
import (
"fmt"
"github.com/carlmjohnson/lich"
)
func main() {
array := lich.ArrayFromStrings("simple", "general", "human-sympathetic")
fmt.Println(array)
}
Output: 40[6<simple>7<general>17<human-sympathetic>]
type DataString ¶
type DataString string
func (DataString) String ¶
func (data DataString) String() string
type Dict ¶
type Dict map[DataString]Element
Example ¶
package main
import (
"fmt"
"github.com/carlmjohnson/lich"
)
func main() {
d1 := lich.Dict{
"selling points": lich.ArrayFromStrings("simple", "general", "human-sympathetic"),
"greeting": lich.DataString([]byte{72, 101, 108, 108, 111}),
"fruit": lich.Array{lich.DataString("apple"), lich.DataString("banana"), lich.DataString("orange")},
}
fmt.Println(d1)
}
Output: 119{5<fruit>26[5<apple>6<banana>6<orange>]8<greeting>5<Hello>14<selling points>40[6<simple>7<general>17<human-sympathetic>]}
func DictFromMap ¶
Example ¶
package main
import (
"fmt"
"github.com/carlmjohnson/lich"
)
func main() {
d2, _ := lich.DictFromMap(map[string]interface{}{
"greeting": map[string]interface{}{
"English": []byte{72, 101, 108, 108, 111},
"Japanese": "Konnichiwa",
},
"fruit": []string{"apple", "banana", "orange"},
"selling points": lich.ArrayFromStrings("simple", "general", "human-sympathetic"),
})
fmt.Println(d2)
}
Output: 158{5<fruit>26[5<apple>6<banana>6<orange>]8<greeting>43{7<English>5<Hello>8<Japanese>10<Konnichiwa>}14<selling points>40[6<simple>7<general>17<human-sympathetic>]}
type UnknownTypeError ¶
type UnknownTypeError struct {
Key string
Value interface{}
}
DictFromMap returns an UnknownTypeError when it encounters values of an unknown type.
func (UnknownTypeError) Error ¶
func (u UnknownTypeError) Error() string
Click to show internal directories.
Click to hide internal directories.