ini

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 3 Imported by: 0

README

ini

GoDoc

The ini package provides a config Decoder that unmarshals values from INI formatted sources.

Example usage:

import (
    "fmt"

    "github.com/warthog618/config"
    "github.com/warthog618/config/blob"
    "github.com/warthog618/config/blob/decoder/ini"
    "github.com/warthog618/config/blob/loader/file"
)

func main() {
    c := config.New(blob.New(file.New("config.ini"), ini.NewDecoder()))
    s := c.MustGet("nested.string").String()
    fmt.Println("s:", s)
    // ....
}

The following option can be applied to ini.NewDecoder:

The WithListSeparator option provides a string used to split list values into elements. The default list separator is ",".

Documentation

Overview

Package ini provides an INI format decoder for config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder provides the Decoder API required by config.Source.

func NewDecoder

func NewDecoder(options ...Option) Decoder

NewDecoder returns a INI decoder.

func (Decoder) Decode

func (d Decoder) Decode(b []byte, v interface{}) error

Decode unmarshals an array of bytes containing ini text.

type Option

type Option func(*Decoder)

Option is a function that modifies the Decdoder during construction, returning any error that may have occurred.

func WithListSeparator

func WithListSeparator(separator string) Option

WithListSeparator sets the separator between slice fields in the ini space. The default separator is ","

Jump to

Keyboard shortcuts

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