Skip to content

Commit

Permalink
refactor: clean up comment, fixing lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdh committed Jan 19, 2022
1 parent 04fc231 commit d37145b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
12 changes: 6 additions & 6 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ func loadConfig() error {
defaults.SetDefaults(&config)
err = viper.Unmarshal(&config)
if err != nil {
return fmt.Errorf("unable to unmarshal config to struct: %v\n", err)
return fmt.Errorf("unable to unmarshal config to struct: %w", err)
}

return nil
}

func bindEnvVars() {
err, configKeys := getFlattenedStructKeys(Config{})
configKeys, err := getFlattenedStructKeys(Config{})
if err != nil {
panic(err)
}
Expand All @@ -89,22 +89,22 @@ func bindEnvVars() {
}
}

func getFlattenedStructKeys(config Config) (error, []string) {
func getFlattenedStructKeys(config Config) ([]string, error) {
var structMap map[string]interface{}
err := mapstructure.Decode(config, &structMap)
if err != nil {
return err, nil
return nil, err
}

flat, err := flatten.Flatten(structMap, "", flatten.DotStyle)
if err != nil {
return err, nil
return nil, err
}

keys := make([]string, 0, len(flat))
for k := range flat {
keys = append(keys, k)
}

return nil, keys
return keys, nil
}
4 changes: 1 addition & 3 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ func initRouter(
if err != nil {
log.Fatal(err)
}
tagTemplateService := tag.NewTemplateService(
templateRepository,
)
tagTemplateService := tag.NewTemplateService(templateRepository)
tagService := tag.NewService(
tagRepository,
tagTemplateService,
Expand Down
1 change: 0 additions & 1 deletion store/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func newTestClient(logger *logrus.Logger) (*postgres.Client, *dockertest.Pool, *
return nil, nil, nil, errors.Wrap(err, "Could not start resource")
}

// pgConfig.Host = "localhost"
pgConfig.Port, err = strconv.Atoi(resource.GetPort("5432/tcp"))
if err != nil {
return nil, nil, nil, errors.Wrap(err, "cannot parse external port of container to int")
Expand Down

0 comments on commit d37145b

Please sign in to comment.