t

ref: structure

config/config.go


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package config

import (
	"os/user"
	"path"
)

type TConfig struct {
	BasePath  string
	GitRemote string
}

func LoadBasicConfiguration() (*TConfig, error) {
	var (
		err error
	)

	currentUser, err := user.Current()

	if err != nil {
		panic("Could not get the current user")
	}

	base := path.Join(currentUser.HomeDir, "notes")

	config := &TConfig{BasePath: base, GitRemote: "origin"}

	return config, err
}

func Initialize() (*TConfig, error) {
	return LoadBasicConfiguration()
}