FieldValue type
Supersedes #11 and #34. Resolves #5 and #26
This is a breaking change
This changes the string type from the Field.Value to a dedicated FieldValue type (backed by a string):
// FieldValue contains the raw field value.
// Use [NewFieldValue] to construct a properly escaped field value.
type FieldValue string
// NewFieldValue creates a new FieldValue after
// escaping each part (backslash, newline, comma)
func NewFieldValue(parts ...string) FieldValue
Users who want the raw value, can call FieldValue.String(). To get escaped values, call FieldValue.Values().
I can confirm that this helps a bit with https://github.com/emersion/go-webdav/issues/173 (conformance test for carddav server)
FYI I am giving a try to a larger refactoring in a dedicated package (loose fork): https://code.pfad.fr/gopim/vcard/
Main differences for users:
- use slices instead of maps (preserves original ordering and casing)
- version is an unexported property
I'm not a fan of this approach in general. If there is no way around it, would prefer some dedicated getter/setter, just like we have for other data types.