diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2017-10-03 14:59:45 +0200 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2017-10-03 15:01:38 +0200 |
commit | 4de510778b6e55a2238374834d00b03726da76d4 (patch) | |
tree | 7b2d8b8f4db5d0bc2b81c8dfb31921fa59d45c6d /objects/properties.go | |
parent | db0c023fd0d756912c3f575c6ac65e99fda573cc (diff) | |
download | petrific-4de510778b6e55a2238374834d00b03726da76d4.tar.gz petrific-4de510778b6e55a2238374834d00b03726da76d4.tar.bz2 petrific-4de510778b6e55a2238374834d00b03726da76d4.zip |
Documentation
Diffstat (limited to 'objects/properties.go')
-rw-r--r-- | objects/properties.go | 13 |
1 files changed, 7 insertions, 6 deletions
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 { |