author

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CanonicalBasename is the canonical name of the file.
	CanonicalBasename = "AUTHORS.txt"
)

Variables

This section is empty.

Functions

func FindFile

func FindFile(path string) (bool, string, error)

Types

type Author

type Author struct {
	Email string
	Name  string
}

type DB

type DB interface {
	Open() error
	Close() error
	Refresh() error
	GetByEmail(string) (bool, *Author)
}

type NoopDB

type NoopDB struct{}

func NewNoopDB

func NewNoopDB() *NoopDB

func (*NoopDB) Close

func (db *NoopDB) Close() error

func (*NoopDB) GetByEmail

func (db *NoopDB) GetByEmail(email string) (bool, *Author)

func (*NoopDB) Open

func (db *NoopDB) Open() error

func (*NoopDB) Refresh

func (db *NoopDB) Refresh() error

type ParseAuthor

type ParseAuthor struct {
	Email string
	Name  string
}

type TxtDB

type TxtDB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DB uses a file commonly known as AUTHORS.txt and provides an interface to lookup information. It is fully synchronized.

func NewTxtDB

func NewTxtDB(path string) (*TxtDB, error)

func (*TxtDB) CalculateHash

func (db *TxtDB) CalculateHash() (string, error)

CalculateHash returns a sha1 sum of the file contents.

func (*TxtDB) Close

func (db *TxtDB) Close() error

func (*TxtDB) GetByEmail

func (db *TxtDB) GetByEmail(email string) (bool, *Author)

GetByEmail looks an author up by her/his email.

func (*TxtDB) IsGone

func (db *TxtDB) IsGone() bool

IsGone checks if the underlying file still exists. This check together with IsStale() can be used to decide whether the need to initialize a new struct or can reuse the current one, and update it from the files contents.

func (*TxtDB) IsStale

func (db *TxtDB) IsStale() bool

func (*TxtDB) Load

func (db *TxtDB) Load() error

Load populates the internal data slice by parsing the underlying file.

func (*TxtDB) Open

func (db *TxtDB) Open() error

func (*TxtDB) Refresh

func (db *TxtDB) Refresh() error

Jump to

Keyboard shortcuts

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