Skip to content

Conversation

@oliverpool
Copy link
Contributor

@oliverpool oliverpool commented Oct 23, 2024

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().

@oliverpool
Copy link
Contributor Author

I can confirm that this helps a bit with emersion/go-webdav#173 (conformance test for carddav server)

Co-authored-by: GorthMohogany <lugo.mark@gmail.com>
@oliverpool
Copy link
Contributor Author

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

@emersion
Copy link
Owner

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.

@oliverpool oliverpool closed this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for properties with multiple values

2 participants