Documentation
¶
Overview ¶
Package vcard defines a vCard, a contact, such as a person or an organisation, which is encoded as vCard 4.0, and decoded from vCard 2.1, 3.0 or 4.0, and its photo, which can be embedded in it, as artwork. Reference: https://www.rfc-editor.org/rfc/rfc6350
Index ¶
Constants ¶
const ( // OmitYear is the year of a birthday whose year isn't known, which is a // leap year, so the 29th of February is a date, as Apple's contacts // write it, with X-APPLE-OMIT-YEAR, so a calendar doesn't show an age OmitYear = 1604 // BirthdayCategory is the category of a birthday's event BirthdayCategory = "Birthdays" )
const ContentType = "text/vcard"
ContentType is the content type of a vCard
const ( // MaxLineSize is the longest line which is read, once it's unfolded, // which includes a photo of several megabytes, as base64 MaxLineSize = 16 << 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
Types []string `json:"types,omitempty"`
POBox string `json:"po_box,omitempty"`
Extended string `json:"extended,omitempty"` // Such as a flat or suite
Street string `json:"street,omitempty"`
Locality string `json:"locality,omitempty"` // Such as a city
Region string `json:"region,omitempty"` // Such as a state or county
PostalCode string `json:"postal_code,omitempty"`
Country string `json:"country,omitempty"`
}
Address is a postal address, with its types, such as home or work, in lower case
type Card ¶
type Card struct {
UID string `json:"uid,omitempty"` // Its unique identifier
Kind string `json:"kind,omitempty"` // individual, group, org or location, or empty for an individual
FN string `json:"fn,omitempty"` // Its formatted name, such as Ada Lovelace
Name Name `json:"name,omitzero"` // The parts of its name
Nicknames []string `json:"nicknames,omitempty"` // Its nicknames
Emails []Value `json:"emails,omitempty"` // Its email addresses
Phones []Value `json:"phones,omitempty"` // Its phone numbers
URLs []Value `json:"urls,omitempty"` // Its URLs
Addresses []Address `json:"addresses,omitempty"` // Its addresses
Orgs []Organization `json:"orgs,omitempty"` // The organisations it's part of
Titles []string `json:"titles,omitempty"` // Its job titles
Birthday *Date `json:"birthday,omitempty"` // Its birthday
Notes []string `json:"notes,omitempty"` // Notes about it
Categories []string `json:"categories,omitempty"` // Its categories, or tags
Photo *Photo `json:"photo,omitempty"` // Its photo, embedded or linked
Rev time.Time `json:"rev,omitzero"` // When it was last changed
}
Card is a contact, such as a person or an organisation
func (*Card) BirthdayCalendar ¶
BirthdayCalendar returns the contact's birthday as a calendar, with an all-day event which repeats every year, from the day they were born, or a leap year when it isn't known, and whose UID is their UID and /birthday, so it's the same each time, in the Birthdays category, so it's known to be a birthday, and which doesn't make the day busy. A birthday on the 29th of February is on the last day of February each year. The event's stamp is when the contact was last changed, or the Unix epoch, so the calendar is the same each time it's written, and its image is their photo, when it's embedded. Returns nil when they have no birthday with a month and a day. Reference: https://www.rfc-editor.org/rfc/rfc5545
func (*Card) DisplayName ¶
DisplayName returns the name of the contact, which is its formatted name, or else the parts of its name, or its first email address, or an empty string when it has none of them
func (*Card) MarshalText ¶
MarshalText returns the contact as vCard 4.0 (see Encoder.Encode)
func (*Card) UnmarshalText ¶
UnmarshalText sets the contact from the first vCard of the text
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads contacts from vCard 2.1, 3.0 or 4.0, one at a time
func NewDecoder ¶
NewDecoder returns a decoder of contacts from r
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes contacts as vCard 4.0
func NewEncoder ¶
NewEncoder returns an encoder of contacts to w
func (*Encoder) Encode ¶
Encode writes the contact as vCard 4.0. Its formatted name, which a vCard must have, is its display name (see Card.DisplayName). Its UID is text, as it may not be a URI, its URLs aren't escaped, as they're URIs, its photo is embedded as a data URI, or linked, and when it was last changed is in UTC. Values which are empty aren't written.
type Name ¶
type Name struct {
Family string `json:"family,omitempty"` // Lovelace
Given string `json:"given,omitempty"` // Ada
Middle string `json:"middle,omitempty"` // Augusta
Prefix string `json:"prefix,omitempty"` // Countess
Suffix string `json:"suffix,omitempty"` // FRS
}
Name is the parts of a name, any of which can be empty
type Organization ¶
type Organization struct {
Name string `json:"name,omitempty"`
Units []string `json:"units,omitempty"`
}
Organization is an organisation, and the units within it, such as a department
func (Organization) String ¶
func (o Organization) String() string
String returns an organisation and its units, separated with commas
type Photo ¶
type Photo struct {
MediaType string `json:"media_type,omitempty"`
Data []byte `json:"data,omitempty"`
URI string `json:"uri,omitempty"`
}
Photo is the photo of a contact, which is embedded in its vCard, as its data and its media type, such as image/jpeg, or linked, as a URI