Skip to content
This repository has been archived by the owner on Dec 27, 2020. It is now read-only.

Declarative way to describe an application's config #58

Open
alldroll opened this issue Jan 27, 2020 · 1 comment
Open

Declarative way to describe an application's config #58

alldroll opened this issue Jan 27, 2020 · 1 comment

Comments

@alldroll
Copy link
Contributor

alldroll commented Jan 27, 2020

The only way to get know about the application's config variables is to look at main.go.

> GRPC_API_PORT=test ENABLE_ENCRYPTION=test scripts/./dev

panic: strconv.ParseBool: parsing "test": invalid syntax

goroutine 1 [running]:
main.mustBool(...)
	/home/alldroll/work/kgs/main.go:88
main.main()
	/home/alldroll/work/kgs/main.go:27 +0xc25
exit status 2

I see several problems here

  • The reported error forces a developer to look at the code line in order to understand what kind of application's config variable is invalid.
  • It is difficult to understand which variables are required, which are optional.

As a solution, we can try to use a struct and the corresponding struct tags

@magicoder10
Copy link
Member

This is now provided by the app framework: https://github.com/short-d/app/blob/master/fw/envconfig/envconfig.go. Need to upgrade kgs to use it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants