goconfig

package module
v0.0.0-...-c37bf87 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 7 Imported by: 0

README

GoConfig

GoConfig, a easy to use configuration parser supporting many different types of configs files as standard and easy to add more if required

click here for examples of this repository

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Defaults map[string]Inclusion = map[string]Inclusion{

	".json": func(b []byte, m map[string]any) error {
		return json.Unmarshal(b, &m)
	},

	".toml": func(b []byte, m map[string]any) error {
		return toml.Unmarshal(b, &m)
	},
}

Defaults represents all the default inclusions registered

Functions

This section is empty.

Types

type GoConfig

type GoConfig struct {
	// contains filtered or unexported fields
}

GoConfig allows you to configure the current working env before actually running the execution routes

func NewConfig

func NewConfig() *GoConfig

NewConfig will create a brand new GoConfig instance

func (*GoConfig) NewInclusion

func (GC *GoConfig) NewInclusion(ext string, exec Inclusion) error

NewInclusion attempts to register the inclusion into the support map

func (*GoConfig) Options

func (GC *GoConfig) Options() (*Options, error)

Options creates a new options window from the config structure

func (*GoConfig) Parse

func (GC *GoConfig) Parse(directories ...string) error

Parse will completely scan all the directories passed inside the vardiac function args

type Inclusion

type Inclusion func([]byte, map[string]any) error

Inclusion allows for you to register your own functions

type Options

type Options struct {
	// contains filtered or unexported fields
}

func (*Options) Get

func (O *Options) Get(t reflect.Kind, p ...string) (any, error)

Get will attempt to retrive the value from the configuration options

func (*Options) MarshalEntire

func (GC *Options) MarshalEntire(v any) error

Marshal will convert the entire options map into a map, then attempt to convert into the corresponding type given

func (*Options) MarshalFromPath

func (GC *Options) MarshalFromPath(v any, path ...string) error

MarshalFromPath allows you to marshal from a specific point inside the map

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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