diary

package module
v0.0.0-...-6daa211 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2016 License: MIT Imports: 4 Imported by: 0

README

= Diary
Jaime Silvela
2014-08-01

Module to provide abstraction to the storage and access of a diary as a file in JSON format.

Documentation

Overview

Package diary defines the Record and Diary structures, defines their file persistence scheme (JSON) and hides these choices from calling modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(writer io.Writer, d Diary) error

Write diary onto file

Types

type Diary

type Diary []Record

Diary represents a diary

func Read

func Read(reader io.Reader) (Diary, error)

Read diary from file

func (*Diary) AddEntry

func (a *Diary) AddEntry(r Record)

AddEntry adds a new record to the diary

func (Diary) LatestHappened

func (a Diary) LatestHappened() (r Record)

LatestHappened gets the record with the latest event time

func (Diary) LatestWritten

func (a Diary) LatestWritten() (r Record)

LatestWritten gets event written last

func (Diary) Len

func (a Diary) Len() int

The Len, Swap and Less functions allow sorting

func (Diary) Less

func (a Diary) Less(i, j int) bool

func (Diary) Swap

func (a Diary) Swap(i, j int)

type Record

type Record struct {
	EventTime   time.Time `json:"eventTime"`
	WrittenTime time.Time `json:"writtenTime"`
	Tags        []string  `json:"tags"`
	Text        string    `json:"text"`
}

Record represents an entry in the diary

func (Record) String

func (r Record) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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