func (cfg *Config) Reload(bind cfgo.BindFunc) error {
	if cfg.init {
		return nil
	}
	err := bind()
	if err != nil {
		return err
	}
	if len(cfg.Addrs) == 0 {
		cfg.Addrs = []string{"127.0.0.1:27017"}
	}
	if len(cfg.Username) == 0 {
		cfg.Username = "root"
	}
	if len(cfg.Database) == 0 {
		cfg.Database = "test"
	}
	cfg.init = true
	return nil
}
Reload sync automatically config from config file.
package mongo
import (
	"time"
	"github.com/henrylee2cn/cfgo"
	"gopkg.in/mgo.v2"
)
type Config struct {
	Addrs    []string      `yaml:"addrs"`
	Timeout  time.Duration `yaml:"timeout"`
	Database string        `yaml:"database"`
	Username string `yaml:"username"`
	Password string `yaml:"passward"`
	PoolLimit int `yaml:"pool_limit"`
	NoCache bool `yaml:"no_cache"`
	init bool
}
var configs = make(map[string]*Config)
func ReadConfig(configSection string) (*Config, error) {
	conf, ok := configs[configSection]
	if ok {
		return conf, nil
	}
	conf = NewConfig()
	err := cfgo.Reg(configSection, conf)
	if err == nil {
		configs[configSection] = conf
		return conf, nil
	} else {
		return nil, err
	}
}
func NewConfig() *Config {
	return &Config{
		Addrs:     []string{"127.0.0.1:27017"},
		Timeout:   10,
		PoolLimit: 256,
		Username:  "root",
		Password:  "",
		Database:  "test",
	}
}