mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-22 18:06:11 +00:00
* chore: bump golang to 1.19 Signed-off-by: Manuel Vogel <mavogel@posteo.de> * fix: [#212] Vulnerabilities. (#219) Co-authored-by: Manuel Vogel <mavogel@posteo.de> * chore: bump all dependencies Signed-off-by: Manuel Vogel <mavogel@posteo.de> * chore(deps): update actions/setup-go action to v3 (#202) Co-authored-by: Renovate Bot <bot@renovateapp.com> * chore(deps): update actions/checkout action to v3 (#201) Co-authored-by: Renovate Bot <bot@renovateapp.com> * chore(deps): update golangci/golangci-lint-action action to v3 (#203) Co-authored-by: Renovate Bot <bot@renovateapp.com> * chore(ci): add explicit go setup before linting Signed-off-by: Manuel Vogel <mavogel@posteo.de> * chore(ci): bump golangci to v1.50.1 Signed-off-by: Manuel Vogel <mavogel@posteo.de> * chore: go fmt Signed-off-by: Manuel Vogel <mavogel@posteo.de> * chore: ignore staticcheck for strings.Title Signed-off-by: Manuel Vogel <mavogel@posteo.de> * chore: reaplce all ioutil with os funcs Signed-off-by: Manuel Vogel <mavogel@posteo.de> * chore ignore file read sec check Signed-off-by: Manuel Vogel <mavogel@posteo.de> * fix: remove unnecessary if before trimPrefix Signed-off-by: Manuel Vogel <mavogel@posteo.de> Signed-off-by: Manuel Vogel <mavogel@posteo.de> Co-authored-by: Ben van B <030@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Renovate Bot <bot@renovateapp.com>
37 lines
566 B
Go
37 lines
566 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
// ConfigLoader ...
|
|
type ConfigLoader interface {
|
|
Load(string) (*Config, error)
|
|
}
|
|
|
|
type configLoaderImpl struct {
|
|
}
|
|
|
|
// NewConfigLoader ...
|
|
func NewConfigLoader() ConfigLoader {
|
|
return &configLoaderImpl{}
|
|
}
|
|
|
|
func (loader *configLoaderImpl) Load(path string) (*Config, error) {
|
|
fp := filepath.Clean(path)
|
|
bytes, err := os.ReadFile(fp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
config := &Config{}
|
|
err = yaml.Unmarshal(bytes, config)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return config, nil
|
|
}
|