Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic on missing key/value #115

Open
gabrieleiannetti opened this issue Jan 18, 2023 · 1 comment
Open

Panic on missing key/value #115

gabrieleiannetti opened this issue Jan 18, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request suggestion

Comments

@gabrieleiannetti
Copy link

Hi,

is there any support for panic on missing config keys and values?

Right now I have a wrapper code that calls the config tool with direct reads to accomplish that:

// Code snippet for panic on missing key/value
func (*ConfigFileReader) MustHaveString(key string) string {
	value := config.String(key)

	if len(value) == 0 {
		log.Panic("Config file key not found or has no value: ", key)
	}

	return value
}

Best
Gabriele

@inhere inhere self-assigned this Feb 1, 2023
@inhere inhere added enhancement New feature or request suggestion labels Feb 1, 2023
@inhere
Copy link
Member

inhere commented Feb 1, 2023

Oh ... you suggestion add like: MustString(), MustInt() ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request suggestion
Projects
None yet
Development

No branches or pull requests

2 participants