Git Product home page Git Product logo

conphig's Introduction

⚙️ Conφg

Spells like "con-phi-g"

A better way to manage Go apps configuration

var PositiveInteger = conphig.New[int, int](
	"positive_integer",
	42,
	conphig.ID[int],
	conphig.WithDescription[int, int]("Positive integer > 0"),
	conphig.WithValidateFunc[int](func(i int) error {
		if i <= 0 {
			return fmt.Errorf("expected >= 0, got %d", i)
		}

		return nil
	}),
)

var FooBar = conphig.New[string, string](
	"foobar",
	"${EDITOR}, $USER and $HOME",
	conphig.ID[string],
	conphig.WithDescription[string, string]("String with env variables"),
	conphig.WithAdjustFunc[string, string](func(s string) (string, error) {
		return os.ExpandEnv(s), nil
	}),
)

var Time = conphig.New[string, time.Time](
	"time",
	time.Now(),
	func(s string) (time.Time, error) {
		return time.Parse(time.Kitchen, s)
	},
)

Note

Work in progress, API may change

How to use

Conphig extends awesome koanf library.

See examples for examples how to use this library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.