From 4de510778b6e55a2238374834d00b03726da76d4 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Tue, 3 Oct 2017 14:59:45 +0200 Subject: Documentation --- objects/properties.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'objects/properties.go') diff --git a/objects/properties.go b/objects/properties.go index 8c92932..2e8c8ac 100644 --- a/objects/properties.go +++ b/objects/properties.go @@ -7,9 +7,10 @@ import ( "sort" ) -// properties are mappings from strings to strings that are encoded as a restricted version of URL query strings -// (only the characters [a-zA-Z0-9.:_-] are allowed, values are ordered by their key) -type properties map[string]string +// Properties are mappings from strings to strings that are encoded as a restricted version of URL query strings +// (only the characters [a-zA-Z0-9.:_-] are allowed, values are ordered by their key. +// This ordering and this character restrictions guarantee reproducible serialization) +type Properties map[string]string // escapePropertyString escapes all bytes not in [a-zA-Z0-9.,:_-] as %XX, where XX represents the hexadecimal value of the byte. // Compatible with URL query strings @@ -29,7 +30,7 @@ func escapePropertyString(s string) []byte { return out } -func (p properties) MarshalText() ([]byte, error) { // Guaranteed to not fail, error is only here to satisfy encoding.TextMarshaler +func (p Properties) MarshalText() ([]byte, error) { // Guaranteed to not fail, error is only here to satisfy encoding.TextMarshaler keys := make([]string, len(p)) i := 0 for k := range p { @@ -57,7 +58,7 @@ func (p properties) MarshalText() ([]byte, error) { // Guaranteed to not fail, e return out, nil } -func (p properties) UnmarshalText(text []byte) error { +func (p Properties) UnmarshalText(text []byte) error { vals, err := url.ParseQuery(string(text)) if err != nil { return err @@ -74,7 +75,7 @@ func (p properties) UnmarshalText(text []byte) error { return nil } -func (a properties) Equals(b properties) bool { +func (a Properties) Equals(b Properties) bool { for k, va := range a { vb, ok := b[k] if !ok || vb != va { -- cgit v1.2.3-54-g00ecf