package module
Version: v0.0.0-...-d961657 Latest Latest

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

Go to latest
Published: Apr 13, 2018 License: Apache-2.0 Imports: 15 Imported by: 1


INI Build Status Sourcegraph

Package go-ini provides INI file read and write functionality in Go.



  • Load multiple data sources([]byte, file and io.ReadCloser) with overwrites.
  • Convenient usage of unmarshal like json.Unmarshal and yaml.Unmarshal.
  • Support section to classify key-value items.
  • Support extend to inherit key-value items from previous section.
  • Read with recursion values.
  • Read and auto-convert values to Go types.
  • Manipulate sections, keys and comments with ease.
  • Read and WRITE comments of sections and keys.
  • Read with multiple-line values.


To use with latest changes:

go get

Please add -u flag to update in the future.

Getting Started

Loading from data sources




View Source
const DEFAULT_SECTION = "default"


This section is empty.


func Marshal

func Marshal(in interface{}) (out []byte, err error)

func Unmarshal

func Unmarshal(in []byte, out interface{}) (err error)


type MapItem

type MapItem struct {
	Key, Value interface{}

MapItem is an item in a MapSlice.

type MapSlice

type MapSlice []MapItem

MapSlice encodes and decodes as a INI map. The order of keys is preserved when encoding and decoding.

type Marshaler

type Marshaler interface {
	MarshalINI() (interface{}, error)

The Marshaler interface may be implemented by types to customize their behavior when being marshaled into a INI document. The returned value is marshaled in place of the original value implementing Marshaler.

If an error is returned by MarshalINI, the marshaling procedure stops and returns with the provided error.

type TypeError

type TypeError struct {
	Errors []string

A TypeError is returned by Unmarshal when one or more fields in the INI document cannot be properly decoded into the requested types. When this error is returned, the value is still unmarshaled partially.

func (*TypeError) Error

func (e *TypeError) Error() string

type Unmarshaler

type Unmarshaler interface {
	UnmarshalINI(unmarshal func(interface{}) error) error

The Unmarshaler interface may be implemented by types to customize their behavior when being unmarshaled from a INI document. The UnmarshalINI method receives a function that may be called to unmarshal the original INI value into a field or variable. It is safe to call the unmarshal function parameter more than once if necessary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL