NewNote returns a new Note
This commit is contained in:
parent
4a006be08f
commit
e7a78a4d33
17
main.go
17
main.go
@ -48,6 +48,14 @@ type Note struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
// NewNote returns a new Note
|
||||
func NewNote(text string) Note {
|
||||
return Note{
|
||||
Time: time.Now(),
|
||||
Text: text,
|
||||
}
|
||||
}
|
||||
|
||||
// Reading holds the glucose and ketone level measurements along with the time the measurements were taken.
|
||||
type Reading struct {
|
||||
Time time.Time `json:"time"`
|
||||
@ -145,10 +153,8 @@ func main() {
|
||||
if err != nil {
|
||||
fmt.Println("Error getting note: %s\n", err)
|
||||
} else {
|
||||
appCtx.AddNote(Note{
|
||||
Time: time.Now(),
|
||||
Text: noteText,
|
||||
})
|
||||
note := NewNote(noteText)
|
||||
appCtx.AddNote(note)
|
||||
}
|
||||
default:
|
||||
fmt.Println("Quitting...")
|
||||
@ -156,6 +162,9 @@ func main() {
|
||||
|
||||
// Save Records before exiting
|
||||
err = appCtx.SaveRecords(recordsFilename)
|
||||
if err != nil {
|
||||
fmt.Printf("Error saving records to file: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func getReading() (Reading, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user