Documentation ¶
Overview ¶
Package calsync helps sync events into a Google Calendar.
Syncing the same set of events into a google calendar a second time will have no effect if the events have not been modified in google calendar. If the events have been modified in google calendar and then are imported again, they will be overwritten, in general.
After you sync events into a google calendar, if you do another sync with the same scope, and you don't include the same events as you did the first time, the missing events will be removed from the google calendar.
All synced events will start with a delimiter string in the description:
====================
Users of google calendar may put any text they like before the delimiter string and this package will maintain that text of the event during any subsequent imports.
We use google calendar private extended properties to store data that lets us re-sync safely. Each created event will have a private extended property of the form <scope>=True and another one of the form <scope>ID=<srcID>. The first private property allows us to query for all matching events in subsequent syncs. The second private propery lets us match up srcEvents with google calendar events in subsequent syncs so we can properly add/update/delete as appropriate.
Index ¶
Constants ¶
const (
// MaxScopeLen is the maximum length we allow for a scope
MaxScopeLen = maxPropLen - maxAppendLen
)
const Scope = calendar.CalendarScope
Scope is the scope we need to read and write calendars.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Changes ¶
type Changes struct {
Deletes, Updates, Adds []*Event
}
Changes represents a set of changes that were made as the result of an Sync call.
func Sync ¶
func Sync( ctx context.Context, client *http.Client, scope string, srcEvents []*Event, opts ...Opt) (*Changes, error)
Sync synchronizes srcEvents into a google calendar. See the package comments for more details.
client is an http client ready to be passed to calendar.New(). An introduction to getting started is here: https://developers.google.com/google-apps/calendar/quickstart/go
scope is described in the package comments. It should be short and unique.
type Event ¶
type Event struct { // Title will be used as the summary in google calendar Title string `json:"title"` Start time.Time `json:"start"` End time.Time `json:"end"` Where string `json:"where"` Description string `json:"description"` // SrcID will be stored in the google calendar event as a private // property and will be used to recognize the same event if you attempt to // sync it again later. It should be unique across all events that you // sync into a single calendar. SrcID string `json:"src_id"` // contains filtered or unexported fields }
Event represents a single synchronizable event.
func (*Event) MarshalJSON ¶
MarshalJSON marshals to json, using RFC 3339 for the start and end fields.
type Opt ¶
type Opt func(c *cal)
Opt is an optional way to configure the Sync command.
func CalendarID ¶
CalendarID will override the default of accessing the users primary calendar, instead accessing the calendar identified by calID.