<commit_before># About ini [![Build Status](https://travis-ci.org/knq/ini.svg)](https://travis-ci.org/knq/ini) #

A simple [Go](http://www.golang.org/project/) package for manipulating 
[ini files](https://en.wikipedia.org/wiki/INI_file).

This package is mostly a simple wrapper around the [parser package](/parser)
also in this repository. The parser package was implemented by generating a 
[Pigeon](https://github.com/PuerkitoBio/pigeon/) parser from a
[PEG grammar](https://en.wikipedia.org/wiki/Parsing_expression_grammar).

This package can (with the correct configuration), correctly read [git
configuration](http://git-scm.com/docs/git-config) files, very simple
[TOML](https://github.com/toml-lang/toml) files, and [Java
Properties](https://en.wikipedia.org/wiki/.properties) files. 

## Why Another ini File Package? ##

Prior to writing this package, a number of existing Go ini packages/parsers
were investigated. The available packages at the time did not have a complete
feature set needed, did not work well with badly formatted files, or their
parsers were not easily fixable.

As such, it was deemed necessary to write a package that could work with a
variety of badly formatted ini files, in idiomatic Go, and provide a simple
interface to reading/writing/manipulating ini files.

## Installation ##

Install the package via the following:

    go get -u github.com/knq/ini

## Usage ##

The ini package can be used similarly to the following:

```go
package main

import (
	"fmt"
	"log"

	"github.com/knq/ini"
)

var (
	data = `
	firstkey = one

	[some section]
	key = blah ; comment

	[another section]<commit_msg>Adding link to GoDoc in README.md<commit_after># About ini [![Build Status](https://travis-ci.org/knq/ini.svg)](https://travis-ci.org/knq/ini) #

A simple [Go](http://www.golang.org/project/) package for manipulating 
[ini files](https://en.wikipedia.org/wiki/INI_file).

This package is mostly a simple wrapper around the [parser package](/parser)
also in this repository. The parser package was implemented by generating a 
[Pigeon](https://github.com/PuerkitoBio/pigeon/) parser from a
[PEG grammar](https://en.wikipedia.org/wiki/Parsing_expression_grammar).

This package can (with the correct configuration), correctly read [git
configuration](http://git-scm.com/docs/git-config) files, very simple
[TOML](https://github.com/toml-lang/toml) files, and [Java
Properties](https://en.wikipedia.org/wiki/.properties) files. 

## Why Another ini File Package? ##

Prior to writing this package, a number of existing Go ini packages/parsers
were investigated. The available packages at the time did not have a complete
feature set needed, did not work well with badly formatted files, or their
parsers were not easily fixable.

As such, it was deemed necessary to write a package that could work with a
variety of badly formatted ini files, in idiomatic Go, and provide a simple
interface to reading/writing/manipulating ini files.

## Installation ##

Install the package via the following:

    go get -u github.com/knq/ini

## Usage ##

Please see [the GoDoc API page](http://godoc.org/github.com/knq/ini) for a full
API listing.

The ini package can be used similarly to the following:

```go
package main

import (
	"fmt"
	"log"

	"github.com/knq/ini"
)

var (
	data = `
	firstkey = one

	[some section]
	key = blah ; comment

	[another section]
{'fraction_non_alphanumeric': 0.10874704491725769, 'fraction_numerical': 0.0, 'mean_word_length': 4.330708661417323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 14, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '996210', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1006, 'n_words': 381}