goconf

package module
v0.0.0-...-9d780c3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2015 License: MIT Imports: 8 Imported by: 3

README

GoConf

GoConf is a JSON configure file loader for golang. It supports multiple layers configure items and can get item value directly by path, etc '/Porject1/ModuleA/Item1'.

It is very simple for use. You can install it by

go get github.com/pantsing/goconf

example_test.go provides an example.

and more details in here http://pan.tsing.cn/?p=118

GoConf用于Golang程序加载JSON格式配置文件,支持多层级配置项及按层级路径读取配置项。 GoConf使用非常简单,你可以通过如下命令安装

go get github.com/pantsing/goconf

在example_test.go中提供了一个示例代码,希望对你有帮助。

更详细的介绍请访问我的博客 http://pan.tsing.cn/?p=118

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func New

func New(filename string) (c *Config, err error)

New function initials a Config and load a JSON format configure file in it.

func NewConfig

func NewConfig() (c *Config)

NewConfig() generates an empty Config struct

func (*Config) Get

func (c *Config) Get(nodePath string, v interface{}) (err error)

Get function read configure item value to the pointer v pointed variate by path, etc. "/ModuleA/SubModule1/itemIntArray" The type of variate that pointer v pointed to MUST be the same type with item value. JSON object type should correspond to struct or map[string]interface{} type in Golang. Get 函数按照配置项的在配置文件中的层次路径,如 "/ModuleA/SubModule1/itemIntArray", 读取配置项的值到指针变量v指向的变量中. v指向的变量必须与配置值数据类型相符,JSON对象类型应对应Golang中Struct类型或Map[string]interface{}类型.

func (*Config) Load

func (c *Config) Load(filename string) (err error)

Load loads JSON format configure file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL