Skip to content

feat(config): adding a configuration loader#116

Merged
julakmane merged 2 commits into
masterfrom
feat/config_loader
May 20, 2026
Merged

feat(config): adding a configuration loader#116
julakmane merged 2 commits into
masterfrom
feat/config_loader

Conversation

@ggresillion

Copy link
Copy Markdown
Contributor

No description provided.

@alkanna

alkanna commented Mar 31, 2026

Copy link
Copy Markdown
Member

Fail sur go vet

Comment thread config/loader.go Outdated

// 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

@julakmane julakmane Apr 1, 2026

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.

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 thread config/loader.go
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 thread config/loader.go Outdated
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

@julakmane julakmane force-pushed the feat/config_loader branch from 2bd6319 to 80c1896 Compare May 20, 2026 13:41
@julakmane julakmane merged commit e10b1e0 into master May 20, 2026
2 checks passed
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