Structured configuration in Go

179 views
Skip to first unread message

Andrew Pillar

unread,
Apr 9, 2022, 10:32:05 AM4/9/22
to golang-nuts
An article I wrote about a new configuration library I developed in Go
for working with structured configuration.

Article:
https://andrewpillar.com/programming/2022/04/09/structured-configuration-in-go/
Repo: https://github.com/andrewpillar/config

Paul Jolly

unread,
Apr 9, 2022, 3:18:32 PM4/9/22
to Andrew Pillar, golang-nuts
Out of interest, have you come across CUE?


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/cce0eeb5a085f6c7539774790d813cef254a4a0b.camel%40andrewpillar.com.

Andrew Pillar

unread,
Apr 9, 2022, 5:19:07 PM4/9/22
to Paul Jolly, golang-nuts
> Out of interest, have you come across CUE?

>
I have heard of it, but not explored it in depth. At a glance it seems
too heavyweight for what I wanted.

Brian Candler

unread,
Apr 10, 2022, 6:19:19 AM4/10/22
to golang-nuts
Cue (and jsonnet) come into their own when building large systems built out of multiple components; they can create configs for multiple applications derived from a shared top-level configuration.  However, the applications themselves don't have to understand cue or jsonnet, since both those can spit out vanilla JSON.

I think there are two big advantages to making your application consume either plain JSON or YAML configs:
1. Everyone is familiar with them
2. You can use a more advanced tool like cue or jsonnet to generate them

I prefer YAML because it's more amenable to direct human management (it allows comments, and is less fussy about commas), whilst still being compatible with machine-generated JSON configs.

Andrew Pillar

unread,
Apr 10, 2022, 6:36:18 AM4/10/22
to Brian Candler, golang-nuts
> I think there are two big advantages to making your application
> consume either plain JSON or YAML configs:
> 1. Everyone is familiar with them
> 2. You can use a more advanced tool like cue or jsonnet to generate
> them

I can see why people would prefer JSON, and I think it's fine for
storing configuration that is edited by the program itself. I don't
think JSON is a very good interface for humans however as it can be
surprisingly verbose at times.

Sam Hughes

unread,
Apr 11, 2022, 2:54:56 AM4/11/22
to golang-nuts
@Paul%20Jolly, me likey! There's a really clean tokenizer implementation, and if nothing else that's really nice baseline to mimic!
Reply all
Reply to author
Forward
0 new messages