// ReadOptionsFile load options from file
ReadOptionsFile load options from file
// ReadOptionsFile load options from file
func ReadOptionsFile(file string, opt *Options) (err error) {
	var buf []byte
	if buf, err = ioutil.ReadFile(file); err != nil {
		return
	}
	if err = yaml.Unmarshal(buf, opt); err != nil {
		return
	}
	if len(opt.Redis.URLs) == 0 {
		err = errors.New("no redis urls in config")
		return
	}
	for _, u := range opt.Redis.URLs {
		if len(u) == 0 {
			err = errors.New("found invalid redis url")
			return
		}
	}
	if len(opt.Redis.Key) == 0 {
		err = errors.New("no redis key in config")
		return
	}
	if len(opt.Mongo.URL) == 0 {
		err = errors.New("no mongo url in config")
		return
	}
	if len(opt.Mongo.DB) == 0 {
		err = errors.New("no mongo db in config")
		return
	}
	if len(opt.Mongo.Collection) == 0 {
		err = errors.New("no mongo collection in config")
		return
	}
	if len(opt.Web.Host) == 0 {
		opt.Web.Host = "127.0.0.1"
	}
	if len(opt.Web.Port) == 0 {
		opt.Web.Port = "3000"
	}
	return
}
func ReadOptionsFile ( file string , opt * Options ) ( err error ) { var buf [ ] byte if buf , err = ioutil . ReadFile ( file ) ; err != nil { return } if err = yaml . Unmarshal ( buf , opt ) ; err != nil { return } if len ( opt . Redis . URLs ) == 0 { err = errors . New ( " " ) return } for _ , u := range opt . Redis . URLs { if len ( u ) == 0 { err = errors . New ( " " ) return } } if len ( opt . Redis . Key ) == 0 { err = errors . New ( " " ) return } if len ( opt . Mongo . URL ) == 0 { err = errors . New ( " " ) return } if len ( opt . Mongo . DB ) == 0 { err = errors . New ( " " ) return } if len ( opt . Mongo . Collection ) == 0 { err = errors . New ( " " ) return } if len ( opt . Web . Host ) == 0 { opt . Web . Host = " " } if len ( opt . Web . Port ) == 0 { opt . Web . Port = " " } return }
ReadOptionsFile load options from file
ReadOptionsFile load options from file