file

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the config directory where files are being stored.

func CreateNewUser

func CreateNewUser(username string) error

CreateNewUser creates our new user.

func ExistingUser

func ExistingUser(username string) bool

ExistingUser tells us if the user exists or not.

func NoExistingUsers

func NoExistingUsers() bool

NoExistingUsers tells us if any users exist.

func OpenUserFile

func OpenUserFile(username string) (f *os.File, err error)

OpenUserFile is used to open up the file for the specified user.

func ReadEncrypted

func ReadEncrypted(r io.Reader, key *[]byte) (content []byte, err error)

ReadEncrypted reads the data from a reader, decrypts it and outputs the content.

Types

type Data

type Data struct {
	Exercise []Exercise `json:"exercise,omitempty"`
}

Data has the xml data for the initial data tag and then incorporates the Exercise struct.

func ReadData

func ReadData(key *[]byte, username string) (exercises Data, err error)

ReadData reads data from an xml file, couldn't be simpler. Unexported.

func ReadEncryptedJSON

func ReadEncryptedJSON(r io.Reader, key *[]byte) (exercises Data, err error)

ReadEncryptedJSON reads encrypted data and then outputs the JSON as a struct.

func ReadJSON

func ReadJSON(r io.Reader) (exercises Data, err error)

ReadJSON is an adaptation of ReadEncryptedJSON that handles already unencrypted JSON text.

func (*Data) Delete

func (d *Data) Delete(username string)

Delete removes all content in the case of a user wanting to start fresh.

func (*Data) Format

func (d *Data) Format(i int) (output string)

Format formats the latest updated data in the Data struct to display information.

func (*Data) Write

func (d *Data) Write(key *[]byte, username string)

Write writes new exercises to the data file.

type Exercise

type Exercise struct {
	Time     time.Time `json:"time,omitempty"`
	Date     string    `json:"date,omitempty"`
	Clock    string    `json:"clock,omitempty"`
	Activity string    `json:"activity,omitempty"`
	Distance float64   `json:"distance,omitempty"`
	Duration float64   `json:"duration,omitempty"`
	Reps     uint32    `json:"reps,omitempty"`
	Sets     uint32    `json:"sets,omitempty"`
	Comment  string    `json:"comment,omitempty"`
}

Exercise keeps track of the data for each exercise that the user has done.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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