GoLang Yaconf::get

request it (341)
GoLang replacement for PHP's Yaconf::get [edit | history]



Do you know a GoLang replacement for PHP's Yaconf::get? Write it!

PHP Yaconf::get

PHP original manual for Yaconf::get [ show | php.net ]

Yaconf::get

(PECL yaconf >= 1.0.0)

Yaconf::getRetrieve a item

Description

public static mixed Yaconf::get ( string $name [, mixed $default_value = NULL ] )

Parameters

name

Configuration key, the key looks like "filename.key", or "filename.sectionName,key".

default_value

if the key doesn't exists, Yaconf::get will return this as result.

Return Values

Returns configuration result(string or array) if the key exists, return default_value if not.

Examples

Example #1 INI()example

;filenmame foo.ini, placed in directory which is yaconf.directoy
[SectionA]
;key value pair
key=val
;hash[a]=val
hash.a=val
;arr[0]=val
arr.0=val
;or
arr[]=val

;SectionB inherits SectionA
[SectionB:SectionA]
;override configuration key in SectionA
key=new_val

The above example will output something similar to:

php7 -r 'var_dump(Yaconf::get("foo.SectionA.key"));'
//string(3) "val"

php7 -r 'var_dump(Yaconf::get("foo.SectionB.key"));'
//string(7) "new_val"

php7 -r 'var_dump(Yaconf::get("foo")["SectionA"]["hash"]);'
//array(1)