1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-06 16:00:18 +00:00

add comments for config package.

This commit is contained in:
傅小黑
2013-12-24 21:57:33 +08:00
parent 5b1afcdb5a
commit 0183608a59
5 changed files with 66 additions and 21 deletions

View File

@ -4,9 +4,10 @@ import (
"fmt"
)
// ConfigContainer defines how to get and set value from configuration raw data.
type ConfigContainer interface {
Set(key, val string) error
String(key string) string
Set(key, val string) error // support section::key type in given key when using ini type.
String(key string) string // support section::key type in key string when using ini and json type; Int,Int64,Bool,Float,DIY are same.
Int(key string) (int, error)
Int64(key string) (int64, error)
Bool(key string) (bool, error)
@ -14,6 +15,7 @@ type ConfigContainer interface {
DIY(key string) (interface{}, error)
}
// Config is the adapter interface for parsing config file to get raw data to ConfigContainer.
type Config interface {
Parse(key string) (ConfigContainer, error)
}
@ -33,8 +35,8 @@ func Register(name string, adapter Config) {
adapters[name] = adapter
}
// adapterNamer is ini/json/xml/yaml
// filename is the config file path
// adapterName is ini/json/xml/yaml.
// filename is the config file path.
func NewConfig(adapterName, fileaname string) (ConfigContainer, error) {
adapter, ok := adapters[adapterName]
if !ok {