init: first init
This commit is contained in:
27
config/parser.go
Normal file
27
config/parser.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"autocal/pkg/autocal"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Parse autocal.yml
|
||||
func ParseAutocal(path string) (*autocal.Autocal, error) {
|
||||
// Open file
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create empty config
|
||||
var autocal autocal.Autocal
|
||||
|
||||
// Unmarshal YAML
|
||||
if err := yaml.Unmarshal(data, &autocal); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &autocal, nil
|
||||
}
|
||||
Reference in New Issue
Block a user