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

Declarative way to describe an application's config #58

@alldroll

Description

@alldroll

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions