MCPcopy Create free account
hub / github.com/archlinux-de/pkgstats-cli / parse

Function parse

internal/config/config.go:17–34  ·  view source on GitHub ↗
(v *viper.Viper)

Source from the content-addressed store, hash-verified

15}
16
17func parse(v *viper.Viper) (*Config, error) {
18 var config Config
19
20 if err := v.ReadInConfig(); err != nil {
21 var configFileNotFoundError viper.ConfigFileNotFoundError
22 if errors.As(err, &configFileNotFoundError) {
23 return &config, nil
24 } else {
25 return nil, fmt.Errorf("failed to read config file %s: %w", v.ConfigFileUsed(), err)
26 }
27 }
28
29 if err := v.UnmarshalExact(&config); err != nil {
30 return nil, fmt.Errorf("failed to parse config file %s: %w", v.ConfigFileUsed(), err)
31 }
32
33 return &config, nil
34}
35
36func Load(configFile string) (*Config, error) {
37 v := viper.New()

Callers 1

LoadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected