You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-taskrem/config.go

35 lines
607 B

package main
import (
"encoding/json"
"os"
)
//TODO: Create:
// * LoadConfig
// * CreateSampleConfig
type Config struct {
Tasks []Task
}
// LoadConfig will take in the filename, load the JSON and return a pointer to Config, a slice of Tasks
func LoadConfig(filename string) (*Config, error) {
file, err := os.ReadFile(filename)
if err != nil {
return nil, err //nil is used here as we return a pointer to Config
}
config := &Config{}
err = json.Unmarshal(file, &config)
if err != nil {
return nil, err
}
return config, nil
}
/*
func CreateSampleConfig() (*Config, error) {
return
}
*/