jsonnet-config-demo-go

module
v0.0.0-...-49a4f26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2023 License: MIT

README

jsonnet-config-demo-go

A Go demo using https://jsonnet.org/ for configuration. Package config provides a generic function MustParse, that evaluates the given config file using jsonnet and unmarshals the generated JSON into the given configuration struct type with exported fields. github.com/go-playground/validator struct tags can be used to constraint individual fields.

In the provided example, the following jsonnet configuration:

local AdminName(name='<untitled>') = 'user_admin_' + name;

{
  host: 'localhost:8080',
  admins: [AdminName(name='Bob'), AdminName(name='Alice')],
}

Is parsed into:

type Config struct {
	Host   string   `json:"host" validate:"required,hostname_port"`
	Admins []string `json:"admins" validate:"required"`
}

Directories

Path Synopsis
cmd
Package config provides a jsonnet configuration file evaluator.
Package config provides a jsonnet configuration file evaluator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL