Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
func Marshal(tp *TextParameters) string
Example ¶
params := ¶meters.TextParameters{
"Foo": "foobar",
"Bar": "golang",
}
encoded := parameters.Marshal(params)
fmt.Println(encoded)
Output: Bar: golang Foo: foobar
Types ¶
type CodingStructPointerError ¶
type CodingStructPointerError struct {
// contains filtered or unexported fields
}
func (*CodingStructPointerError) Error ¶
func (e *CodingStructPointerError) Error() string
type DecodeFieldTypeError ¶
type DecodeFieldTypeError struct {
// contains filtered or unexported fields
}
func (*DecodeFieldTypeError) Error ¶
func (e *DecodeFieldTypeError) Error() string
type DecodeFormatError ¶
type DecodeFormatError struct {
// contains filtered or unexported fields
}
func (*DecodeFormatError) Error ¶
func (e *DecodeFormatError) Error() string
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Example ¶
body := `Foo: 3.14
barbaz: golang
Piyo: 123`
s := struct {
Foo float64
Bar string `parameters:"barbaz"`
Piyo int
}{}
decoder := parameters.NewDecorder(strings.NewReader(body))
decoder.Decode(&s)
fmt.Println("s.Foo =", s.Foo)
fmt.Println("s.Bar =", s.Bar)
fmt.Println("s.Piyo =", s.Piyo)
Output: s.Foo = 3.14 s.Bar = golang s.Piyo = 123
func NewDecorder ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Example ¶
s := struct {
Foo float64
Piyo int
Bar string `parameters:"barbaz"`
}{
Foo: 1.41421356,
Piyo: 12345,
Bar: "golang",
}
var b bytes.Buffer
encoder := parameters.NewEncoder(&b)
encoder.Encode(&s)
fmt.Print(b.String())
Output: Foo: 1.41421356 Piyo: 12345 barbaz: golang
func NewEncoder ¶
type TextParameters ¶
func Unmarshal ¶
func Unmarshal(r io.Reader) (*TextParameters, error)
Example ¶
body := `foo: 3
bar: 4
baz: 5`
obj, _ := parameters.Unmarshal(strings.NewReader(body))
fmt.Println(obj.Get("foo"), obj.Get("bar"), obj.Get("baz"))
Output: 3 4 5
func (TextParameters) Del ¶
func (t TextParameters) Del(key string)
func (TextParameters) Get ¶
func (t TextParameters) Get(key string) string
func (TextParameters) Keys ¶
func (t TextParameters) Keys() []string
func (TextParameters) Set ¶
func (t TextParameters) Set(key, value string)
Click to show internal directories.
Click to hide internal directories.
