This message was deleted.
# golang
s
This message was deleted.
c
Just FYI, there's
config.Require
if you want to err when a key is missing
p
thank you @careful-bird-79707, I'll amend my code. Appreciate your input.
🙌 1
looks better now, simpler 🙂
Copy code
var crtArn = config.Require(ctx, "certificate:arn")
		var vpcID = config.Require(ctx, "vpc:id")
c
Definitely 🙂 I'm usually very stringent about not panic'ing but in this case it ain't too bad
p
In this case I actually find it brilliant to panic
s
A pattern you’ll see in some of our architecture templates is this:
Copy code
minClusterSize, err := cfg.TryInt("minClusterSize")
if err != nil {
    minClusterSize = 3
}
This has the effect of setting a default value if the configuration value isn’t set. If you prefer to have the program error out, then
Require
is the way to go IMO.
p
thank you @salmon-account-74572, I have in mind some use cases for this approach as well!
s
Happy to help!
❤️ 1