goprops

package module
Version: v0.0.0-...-3a6c6d2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2016 License: MIT Imports: 6 Imported by: 0

README

goprops

A Go library to read and write Java properties file.

How to Get It
go get github.com/fredyw/goprops
Usage
package main

import (
	"fmt"
	"os"
	"github.com/fredyw/goprops"
)

func testRead() {
	props, err := goprops.ReadFile("in.properties")
	if err != nil {
		fmt.Println("Error:", err)
		os.Exit(1)
	}
	for key, value := range props {
		fmt.Println(key, "=", value)
	}
}

func testWrite() {
	props := goprops.Properties{}
	props["key1"] = "value1"
	props["key2"] = "value2"
	props["key3"] = "value3"
	err := goprops.WriteFile("out.properties", props)
	if err != nil {
		fmt.Println("Error:", err)
		os.Exit(1)
	}
}

func main() {
	testRead()
	testWrite()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(out io.Writer, props Properties)

Write writes properties into a writer

func WriteFile

func WriteFile(fileName string, props Properties) error

WriteFile writes properties into a file

Types

type Properties

type Properties map[string]string

Properties contains the list of properties

func Read

func Read(in io.Reader) (Properties, error)

Read reads properties from a reader.

func ReadFile

func ReadFile(fileName string) (Properties, error)

ReadFile reads properties from a file.

Source Files

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