Skip to content

feat(config): adding a configuration loader#116

Open
ggresillion wants to merge 4 commits intomasterfrom
feat/config_loader
Open

feat(config): adding a configuration loader#116
ggresillion wants to merge 4 commits intomasterfrom
feat/config_loader

Conversation

@ggresillion
Copy link
Copy Markdown
Contributor

No description provided.

@alkanna
Copy link
Copy Markdown
Member

alkanna commented Mar 31, 2026

Fail sur go vet


// MustErr panics if any error was encountered during loading.
// Useful for fail-fast initialisation in main().
func (l *Loader) MustErr() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas fan du naming

Peut-être just Must ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

@julakmane julakmane Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())
}

Comment on lines +69 to +72
// 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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤔

Comment on lines +92 to +94
if l.err != nil {
return fallback
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants