lists
This commit is contained in:
@@ -2,31 +2,72 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"example.com/note/note"
|
||||
"example.com/note/todo"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type saver interface {
|
||||
Save() error
|
||||
}
|
||||
|
||||
// type displayer interface {
|
||||
// Display()
|
||||
// }
|
||||
|
||||
type outputtable interface {
|
||||
saver
|
||||
Display()
|
||||
}
|
||||
|
||||
// type outputtable interface {
|
||||
// Save() error
|
||||
// Display()
|
||||
// }
|
||||
|
||||
func main() {
|
||||
title, content := getNoteData()
|
||||
todoText := getUserInput("Todo text: ")
|
||||
|
||||
userNote, err := note.New(title, content)
|
||||
todo, err := todo.New(todoText)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
userNote.Display()
|
||||
err = userNote.Save()
|
||||
userNote, err := note.New(title, content)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Saving the note failed")
|
||||
return
|
||||
}
|
||||
|
||||
err = outputData(todo)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
outputData(userNote)
|
||||
}
|
||||
|
||||
func outputData(data outputtable) error {
|
||||
data.Display()
|
||||
return saveData(data)
|
||||
}
|
||||
|
||||
func saveData(data saver) error {
|
||||
err := data.Save()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Saving the note failed")
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Saving the note succeeded!")
|
||||
return nil
|
||||
}
|
||||
|
||||
func getNoteData() (string, string) {
|
||||
|
||||
Reference in New Issue
Block a user