vcard

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2022 License: MIT Imports: 9 Imported by: 1

README

build

vcard-go

A minimal library to manipulate VCard file using Golang. This library is based on RFC6350.

Installation

git clone https://github.com/mapaiva/vcard-go.git
cd vcard-go
make install

Usage


import (
	"github.com/mapaiva/vcard-go"
	"log"
)

func main() {
	cards, err := vcard.GetVCards("~/contacts.vcf")

	if err != nil {
		log.Fatal(err)
	}

	log.Println(cards)
}

Testing

make test

Lint

make lint

Documentation

Complete documentation available on https://godoc.org/github.com/mapaiva/vcard-go.

Documentation

Overview

Package vcard is a library made to decode vCard files into readable golang structs.

Index

Constants

View Source
const (
	// VCardTagName represents the tag name used inside the struct VCard.
	VCardTagName = "vcard"

	// VCardVersion represents the supported version of vCard.
	VCardVersion = "2.1"
)

Variables

View Source
var (
	// ErrUnsupportedType indicates that an unsupported interface type was sent for conversion.
	ErrUnsupportedType = errors.New("unsupported type")
)

Functions

func Marshal added in v1.1.0

func Marshal(v interface{}) ([]byte, error)

Marshal returns the vCard encoding of v.

Types

type VCard

type VCard struct {
	StructuredName  string `vcard:"N"`
	FormattedName   string `vcard:"FN"`
	Email           string `vcard:"EMAIL"`
	Version         string `vcard:"VERSION"`
	Addr            string `vcard:"ADR"`
	Anniversary     string `vcard:"ANNIVERSARY"`
	BirthDay        string `vcard:"BDAY"`
	Nickname        string `vcard:"NICKNAME"`
	Photo           string `vcard:"PHOTO"`
	CalendarAddrURI string `vcard:"CALADRURI"`
	CalendarURI     string `vcard:"CALURI"`
	Categories      string `vcard:"CATEGORIES"`
	Class           string `vcard:"CLASS"`
	ClientIDMap     string `vcard:"CLIENTIDMAP"`
	FreeOrBusyURL   string `vcard:"FBURL"`
	Gender          string `vcard:"GENDER"`
	Geolocation     string `vcard:"GEO"`
	Key             string `vcard:"KEY"`
	Kind            string `vcard:"KIND"`
	Language        string `vcard:"LANG"`
	Mailer          string `vcard:"MAILER"`
	Member          string `vcard:"MEMBER"`
	Note            string `vcard:"NOTE"`
	Organization    string `vcard:"ORG"`
	ProdID          string `vcard:"PRODID"`
	Profile         string `vcard:"PROFILE"`
	Related         string `vcard:"RELATED"`
	Revision        string `vcard:"REV"`
	Role            string `vcard:"ROLE"`
	Sound           string `vcard:"SOUND"`
	Source          string `vcard:"SOURCE"`
	Phone           string `vcard:"TEL"`
	Title           string `vcard:"TITLE"`
	TimeZone        string `vcard:"TZ"`
	UID             string `vcard:"UID"`
	URL             string `vcard:"URL"`
	XML             string `vcard:"XML"`

	// Additional properties
	BirthPlace            string `vcard:"BIRTHPLACE"`
	DeathPlace            string `vcard:"DEATHPLACE"`
	DeathDate             string `vcard:"DEATHDATE"`
	Expertise             string `vcard:"EXPERTISE"`
	Hobby                 string `vcard:"HOBBY"`
	InstantMessenger      string `vcard:"IMPP"`
	Interest              string `vcard:"INTEREST"`
	OrganizationDirectory string `vcard:"ORG-DIRECTORY"`
}

VCard represents a single vCard with its fields.

func GetVCards

func GetVCards(path string) ([]VCard, error)

GetVCards returns a list of vCard based on a file path.

func GetVCardsByFile

func GetVCardsByFile(f *os.File) ([]VCard, error)

GetVCardsByFile returns a list of vCard retrived from a golang *os.File.

func GetVCardsByReader

func GetVCardsByReader(r io.Reader) ([]VCard, error)

GetVCardsByReader returns a list of vCards given an io.Reader.

Directories

Path Synopsis
Package prop contains all vCard properties based on version 4.
Package prop contains all vCard properties based on version 4.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL