Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FieldValue type #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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 <[email protected]>
@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.

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