feat(config): adding a configuration loader#116
Conversation
|
Fail sur go vet |
|
|
||
| // MustErr panics if any error was encountered during loading. | ||
| // Useful for fail-fast initialisation in main(). | ||
| func (l *Loader) MustErr() { |
There was a problem hiding this comment.
pas fan du naming
Peut-être just Must ?
There was a problem hiding this comment.
pas fan du naming
Pour me justifier : must est normalement suivi d'un verbe
Du coup ma suggestion n'est pas terrible non plus, mais je ne trouve pas le bon verbe
There was a problem hiding this comment.
j'aime bien juste Must, l'habitude avec les uuid google sûrement
https://github.com/google/uuid/blob/master/uuid.go#L210
// Must returns uuid if err is nil and panics otherwise.
func Must(uuid UUID, err error) UUID {
if err != nil {
panic(err)
}
return uuid
}
// New creates a new random UUID or panics. New is equivalent to
// the expression
//
// uuid.Must(uuid.NewRandom())
func New() UUID {
return Must(NewRandom())
}
| // Required returns the string value of key. If the key is unset, it | ||
| // records an error and returns an empty string. Use when there is no | ||
| // sensible fallback. | ||
| func (l *Loader) Required(key string) string { |
There was a problem hiding this comment.
Pas de "Required" pour autre chose que les string ?
Ah, l'idée est peut-être de faire
_ = loader.Required("toto")
value = loader.Int64("toto", 42)
Je me demande si il n'y a pas une meilleure interface possible 🤔
| if l.err != nil { | ||
| return fallback | ||
| } |
There was a problem hiding this comment.
on s'arrête à la première erreur ?
On pourrait stocker une slice puis les errors.Join pour voir tous les soucis d'un coup plutôt que 1 par 1
No description provided.