conf

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 6

README

Opinionated configuration management for Go tools

GoDoc License

Documentation

Overview

Package conf provides a high-level abstraction over methods to manage user configuration stored under $XDG_CONFIG_DIR. Being opinionated, all configuration is written and read in YAML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C

type C struct{}

C encompasses various methods to read, write and query config file.

func New

func New() *C

New creates a new instance of C. It is mandatory to run the Init() method immediately after.

func (*C) Data

func (c *C) Data() ([]byte, error)

Data returns the contents of the configuration file.

func (*C) Init

func (c *C) Init() error

Init creates the necessary config directory and file (if absent). It is mandatory to call this method before performing any operations.

func (*C) MustInit

func (c *C) MustInit()

MustInit is same as Init but exits the program in case of an error.

func (*C) Query

func (c *C) Query(q string) (string, error)

Query evaluates the yaml query and returns the result (in string).

func (*C) Read

func (c *C) Read(out any) error

Read reads and marshals the config file into `out`. `out` must therefore be passed by reference.

func (*C) Write

func (c *C) Write(in any) error

Write writes the configurations to the config path.

Directories

Path Synopsis
internal
util
Package util provides reusable helper function.
Package util provides reusable helper function.
Package vars provides a high-level abstraction over an internal concurrency safe map object and operations like Get, Set, Del & Exists for management of temporary local cache.
Package vars provides a high-level abstraction over an internal concurrency safe map object and operations like Get, Set, Del & Exists for management of temporary local cache.

Jump to

Keyboard shortcuts

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