Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>
Add Note's Title method
config/config.go | 36 +++++++++++++++++++----------------- models/models.go | 12 ++++++++++--
diff --git a/config/config.go b/config/config.go index 96b668630bee926630017fc04d1c97cb5da5a975..6064399a4f14604076ae44acfa9e73860157945b 100644 --- a/config/config.go +++ b/config/config.go @@ -1,36 +1,38 @@ package config import ( - "path" - "fmt" - "os/user" + "fmt" + "os/user" + "path" ) type TConfig struct { - BasePath string - GitRemote string + BasePath string + GitRemote string } func LoadBasicConfiguration() (*TConfig, error) { - var ( - err error - ) + var ( + err error + ) - currentUser, err := user.Current() + currentUser, err := user.Current() - if err != nil { - panic("Could not get the current user") - } + if err != nil { + panic("Could not get the current user") + } - base := path.Join(currentUser.HomeDir, "notes") + base := path.Join(currentUser.HomeDir, "notes") - fmt.Println(base) + fmt.Println(base) + + config := &TConfig{BasePath: base, GitRemote: "origin"} - config := &TConfig{BasePath: base, GitRemote: "origin"} + fmt.Println(config) - return config, err + return config, err } func Initialize() (*TConfig, error) { - return LoadBasicConfiguration() + return LoadBasicConfiguration() } diff --git a/models/models.go b/models/models.go index 9c2938a6c1188c7a50cddf81a86748e490995e4e..52125a93dfd63cab8bba30be7a28732a8bd7621c 100644 --- a/models/models.go +++ b/models/models.go @@ -1,6 +1,14 @@ package models +import ( + "strings" +) + type Note struct { - Name string - Path string + Name string + Path string +} + +func (note *Note) Title() string { + return strings.Split(note.Name, ".")[0] }