Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
refactor: the config should not be changeable after filled
Browse files Browse the repository at this point in the history
  • Loading branch information
calmonr committed Sep 16, 2022
1 parent a3d9d4b commit a9fb427
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmd/playground/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ type Config struct {
}
}

func (c *Config) Fill() {
func (c Config) Fill() Config {
// grpc server
c.GRPCServer.Address = viper.GetString(PrefixGRPCServer + SuffixAddress)
c.GRPCServer.Network = viper.GetString(PrefixGRPCServer + SuffixNetwork)

return c
}
3 changes: 1 addition & 2 deletions cmd/playground/app/runnable/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ func NewRoot() command.Runnable {
}
}

cfg := new(app.Config)
cfg.Fill()
cfg := new(app.Config).Fill()

listener, err := net.Listen(cfg.GRPCServer.Network, cfg.GRPCServer.Address)
if err != nil {
Expand Down

0 comments on commit a9fb427

Please sign in to comment.