Treat circular references and malformed expressions as errors.
Add Set() method for setting values.
Renamed GetDefault() to GetString().
Added GetFloat, GetInt, GetUint and GetBool convenience methods.
6 files changed
tree: 1301e297e0481e13b5bdf5c8add32d126839d2b1
  1. doc.go
  2. example_test.go
  3. lex.go
  4. LICENSE
  5. load.go
  6. load_test.go
  7. parser.go
  8. properties.go
  9. properties_test.go
  10. README.md
README.md

Overview

goproperties is a Go library for reading and writing Java property files.

It supports reading properties from multiple files and Spring style property expansion of expressions of ‘${key}’ to their corresponding value.

The current version supports reading both ISO-8859-1 and UTF-8 encoded data.

Install

$ go get github.com/magiconair/goproperties

Usage

p := goproperties.MustLoadFile(filename, goproperties.ISO_8859_1)
value, ok := p.Get("key")
if ok {
	fmt.Println(value)
}

or

// load multiple files and ignore missing files
p := goproperties.MustLoadFiles([]string{filename1, filename2}, true, goproperties.ISO_8859_1)
value, ok := p.Get("key")
if ok {
	fmt.Println(value)
}

History

v1.0, 6 Jan 2014 - Initial release

License

2 clause BSD license. See LICENSE file for details.