Giter Site home page Giter Site logo

inifile's Introduction

build coverage goreport Docs

inifile

Simple INI file reader.

Section and key names are case-insensitive and ignore leading and trailing whitespace.

Supports line comments, trailing comments and quoted values.

Keys appearing more than once will either replace previous values or append to them with a separator.

func ExampleParse() {
	const initext = `
# comments start with a hash
; or a semicolon

# global keys are in the unnamed (empty string) section
Username = " user name " # values can be quoted preserve whitespace or embed quotes

# section names are case insensitive and ignores leading and trailing whitespace
[ HTTP ] 
 port = 8080 # keys and values are stripped of leading and trailing whitespace
port=8081 # keys appearing more than once either append or replace values
`

	inif, err := inifile.Parse(strings.NewReader(initext), ',')
	if err != nil {
		fmt.Fprint(os.Stderr, err)
	}
	username, _ := inif.Get("", "username")
	ports, _ := inif.Get("http", "port")

	fmt.Printf("%q\n%q\n", username, ports)
	// Output:
	// " user name "
	// "8080,8081"
}

inifile's People

Contributors

linkdata avatar

Stargazers

Daniel Sokil avatar

Watchers

 avatar  avatar

Forkers

s0kil

inifile's Issues

Respect case sensitivity in strings

@linkdata

Hey, thanks for sharing this lib!

One little issue I can across is that uppercase chars are parsed and lowercased:

Example, INI File

[56A1B3]
en=SM`A`'s `B`chip does not return to the nonce at all

The 56A1B3 is parsed as 56a1b3 by the library

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.