Skip to content

Commit

Permalink
pointer in main only
Browse files Browse the repository at this point in the history
  • Loading branch information
LdDl committed Oct 22, 2024
1 parent 32cedea commit c15d963
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/video_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func main() {
}
defer pprof.StopCPUProfile()
}
appCfg, err := configuration.PrepareConfiguration(conf)
appCfg, err := configuration.PrepareConfiguration(*conf)
if err != nil {
log.Error().Err(err).Str("scope", videoserver.SCOPE_CONFIGURATION).Msg("Could not prepare application configuration")
return
Expand Down
12 changes: 6 additions & 6 deletions configuration/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ import (
"github.com/pkg/errors"
)

func PrepareConfiguration(confName *string) (*Configuration, error) {
func PrepareConfiguration(confName string) (*Configuration, error) {
var err error
if confName == nil || *confName == "" {
if confName == "" {
errReason := "Empty file name"
return nil, errors.Wrap(err, errReason)
}

fileNames := strings.Split(*confName, ".")
fileNames := strings.Split(confName, ".")
if len(fileNames) != 2 {
errReason := fmt.Sprintf("Bad file name '%s'", *confName)
errReason := fmt.Sprintf("Bad file name '%s'", confName)
return nil, errors.Wrap(err, errReason)
}
fileFormat := fileNames[1]

switch fileFormat {
case "json":
mainCfg, err := PrepareConfigurationJSON(*confName)
mainCfg, err := PrepareConfigurationJSON(confName)
if err != nil {
return nil, err
}
return mainCfg, nil
case "toml":
mainCfg, err := PrepareConfigurationTOML(*confName)
mainCfg, err := PrepareConfigurationTOML(confName)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit c15d963

Please sign in to comment.