• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang config.NewConfig函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/astaxie/beego/config.NewConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang NewConfig函数的具体用法?Golang NewConfig怎么用?Golang NewConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewConfig函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: getConfig

func getConfig() (conf config.Configer, err error) {
	home := os.Getenv("HOME")
	if home != "" {
		homePath := filepath.Join(home, ".dockyard", "containerops.conf")
		conf, err = config.NewConfig("ini", homePath)
	}

	if err != nil {
		conf, err = config.NewConfig("ini", "conf/containerops.conf")
	}

	return
}
开发者ID:pombredanne,项目名称:dockyard,代码行数:13,代码来源:setting.go


示例2: amazons3getconfig

func amazons3getconfig(conffile string) (err error) {
	conf, err := config.NewConfig("ini", conffile)
	if err != nil {
		return err
	}

	g_amazons3Endpoint = conf.String("amazons3cloud::endpoint")
	if g_amazons3Endpoint == "" {
		return errors.New("read config file's endpoint failed!")
	}

	g_amazons3Bucket = conf.String("amazons3cloud::bucket")
	if g_amazons3Bucket == "" {
		return errors.New("read config file's bucket failed!")
	}

	g_amazons3AccessKeyID = conf.String("amazons3cloud::accessKeyID")
	if g_amazons3AccessKeyID == "" {
		return errors.New("read config file's accessKeyID failed!")
	}

	g_amazons3AccessKeySecret = conf.String("amazons3cloud::accessKeysecret")
	if g_amazons3AccessKeySecret == "" {
		return errors.New("read config file's accessKeysecret failed!")
	}
	return nil
}
开发者ID:haoyuist,项目名称:dockyard,代码行数:27,代码来源:amazons3cloud.go


示例3: Get

func (this *Configuration) Get() config.ConfigContainer {
	data, error := config.NewConfig("yaml", "./conf/app.yml")
	if error != nil {
		log.Fatal(error)
	}
	return data
}
开发者ID:nokia-wroclaw,项目名称:hackathon-goidea,代码行数:7,代码来源:config.go


示例4: qiniugetconfig

func qiniugetconfig(conffile string) (err error) {
	var conf config.ConfigContainer
	conf, err = config.NewConfig("ini", conffile)
	if err != nil {
		return err
	}

	g_qiniuEndpoint = conf.String("qiniucloud::endpoint")
	if g_qiniuEndpoint == "" {
		return errors.New("read config file's endpoint failed!")
	}

	g_qiniuBucket = conf.String("qiniucloud::bucket")
	if g_qiniuBucket == "" {
		return errors.New("read config file's bucket failed!")
	}

	g_qiniuAccessKeyID = conf.String("qiniucloud::accessKeyID")
	if g_qiniuAccessKeyID == "" {
		return errors.New("read config file's accessKeyID failed!")
	}

	g_qiniuAccessKeySecret = conf.String("qiniucloud::accessKeysecret")
	if g_qiniuAccessKeySecret == "" {
		return errors.New("read config file's accessKeysecret failed!")
	}
	return nil
}
开发者ID:haoyuist,项目名称:dockyard,代码行数:28,代码来源:qiniu.go


示例5: init

func init() {

	cmd, err := notify.NewCmd("telegram-cli", "-C")

	if err != nil {
		log.Fatal("NewCmd error", err)
	}

	botConf = Conf{
		Limit: 10,
		Url:   "localhost",
		Rpms:  500,
		Cmd:   cmd,
	}

	//Init Data Mapper
	c, err := beeconf.NewConfig("ini", "../../conf/app.conf")

	if err != nil {
		log.Fatal(err)
	}

	TestConfig, err := conf.Initialize("test", c)
	if err != nil {
		log.Fatal(err)
	}

	if err := M.DbOpen(TestConfig.Db); err != nil {
		log.Fatal(err)
	}

	M.PrepareTables(&M.Cand{})
	Tfn, _ := i18n.Tfunc("en-us", "en-us", "en-us")
	M.T = Tfn
}
开发者ID:grr89,项目名称:hrkb,代码行数:35,代码来源:bot_test.go


示例6: main

func main() {
	tracelog.StartFile(tracelog.LevelTrace, "logs", 1)
	tracelog.Started("main", "Initializing Postgres")
	var confName string = os.Getenv("BOOKS_CONF")
	if len(confName) == 0 {
		confName = "default"
	}
	s := []string{"conf/db/", confName, ".json"}
	jsonconf, err := config.NewConfig("json", strings.Join(s, ""))
	if err != nil {
		tracelog.Errorf(err, "main", "config.NewConfig", "Failed to find config", strings.Join(s, ""))
	}
	var User string = jsonconf.String("User")
	var Pass string = jsonconf.String("Pass")
	var DBName string = jsonconf.String("DBName")
	var buffer bytes.Buffer
	buffer.WriteString("user=")
	buffer.WriteString(User)
	buffer.WriteString(" password=")
	buffer.WriteString(Pass)
	buffer.WriteString(" dbname=")
	buffer.WriteString(DBName)
	s2 := []string{"user=", User, " password=", Pass, " dbname=", DBName, " sslmode=disable"}
	orm.RegisterDriver("postgres", orm.DR_Postgres)
	orm.RegisterDataBase("default", "postgres", strings.Join(s2, ""))
	beego.SetStaticPath("/images", "static/images")
	beego.SetStaticPath("/css", "static/css")
	beego.SetStaticPath("/js", "static/js")
	beego.SetStaticPath("/fonts", "static/fonts")
	beego.SetStaticPath("/partials", "static/partials")
	beego.EnableAdmin = true
	orm.RunCommand()
	beego.Run()
}
开发者ID:tshahmuratov,项目名称:GoCRUD,代码行数:34,代码来源:main.go


示例7: init

func init() {
	duangcfg, err := config.NewConfig("ini", "conf/duang.conf")
	if err != nil {
		fmt.Println(err)
		return
	}
	orm.RegisterDriver("mysql", orm.DR_MySQL)
	orm.RegisterDataBase("default", "mysql", fmt.Sprintf("%s:%[email protected]%s/%s?charset=utf8", duangcfg.String("db_user"), duangcfg.String("db_pass"), duangcfg.String("db_addr"), duangcfg.String("db_name")))

	orm.RegisterModel(
		new(Unit),
		new(UnitParameter),
		new(Dockerd),
		new(Ip),
		new(Container),
		//new(Frontend),
		//new(Backend),
	)

	force, err := duangcfg.Bool("db_dropifexist")
	if err != nil {
		force = false
	}

	verbose := true
	err = orm.RunSyncdb("default", force, verbose)
	if err != nil {
		beego.Error(err)
	}

}
开发者ID:lilwulin,项目名称:duang,代码行数:31,代码来源:init.go


示例8: Test_upyunsave

func Test_upyunsave(t *testing.T) {
	var err error
	var conf config.ConfigContainer
	var url string

	conf, err = config.NewConfig("ini", "../../../conf/containerops.conf")
	if err != nil {
		t.Error(err)
	}

	d := new(UpyunDrv)
	err = d.ReadConfig(conf)
	if err != nil {
		t.Error(err)
	}

	file := "upyun_test.go"
	url, err = upyunsave(file)
	if err != nil {
		t.Error(err)
	}
	_, err = http.Get(url)
	if err != nil {
		t.Error(err)
	}
}
开发者ID:m20082008m,项目名称:dockyard,代码行数:26,代码来源:upyun_test.go


示例9: newAppConfig

func newAppConfig(appConfigProvider, appConfigPath string) (*beegoAppConfig, error) {
	ac, err := config.NewConfig(appConfigProvider, appConfigPath)
	if err != nil {
		return nil, err
	}
	return &beegoAppConfig{ac}, nil
}
开发者ID:chaws,项目名称:beego,代码行数:7,代码来源:config.go


示例10: initORM

func initORM() {
	if ormInitiated {
		return
	}
	appConf, err := config.NewConfig("ini", "conf/app.conf")
	if err != nil {
		panic(err)
	}
	dbAddr := appConf.String("admin::dbAddr")
	dbUser := appConf.String("admin::dbUser")
	dbPass := appConf.String("admin::dbPass")
	controllers.ALI_YUN_AK_ID = appConf.String("admin::akId")
	controllers.ALI_YUN_AK_KEY = appConf.String("admin::akKey")
	controllers.QQ_OAUTH_CONSUMER_KEY = appConf.String("admin::qqOAuthConsumerKey")
	clientId := appConf.String("admin::clientId")
	clientSecret := appConf.String("admin::clientSecret")
	controllers.BASIC_AUTH_AUTHORIZATION = utils.Base64(clientId + ":" + clientSecret)

	controllers.VISITOR_TOKEN = appConf.String("admin::visitorToken")

	orm.RegisterDriver("mymysql", orm.DRMySQL)
	conn := fmt.Sprintf("%s:%[email protected](%s)/beego_unit_test?charset=utf8mb4", dbUser, dbPass, dbAddr)
	orm.RegisterDataBase("default", "mysql", conn)
	ormInitiated = true
}
开发者ID:Piasy,项目名称:BeegoTDDBootStrap,代码行数:25,代码来源:common_ops.go


示例11: NewConfig

func NewConfig(file string) (Configure, error) {
	appConfigPath, isCurrentDir, err := findAppConfPath(file)
	if err != nil {
		return nil, err
	}
	configer, err := config.NewConfig("ini", appConfigPath)
	if err != nil {
		return nil, err
	}

	var runMode string
	if isCurrentDir == false {
		runMode = "test"
	} else if envRunMode := os.Getenv("BEEGO_RUNMODE"); envRunMode != "" {
		runMode = envRunMode
	} else if configRunMode := configer.String("RunMode"); configRunMode != "" {
		runMode = configRunMode
	} else {
		runMode = "dev"
	}

	return &configureImplement{
		runMode:  runMode,
		configer: configer,
	}, nil
}
开发者ID:fishedee,项目名称:fishgo,代码行数:26,代码来源:util_configure.go


示例12: Get

func (c *ZhouBianWifiWXController) Get() {
	op := c.Input().Get("op")
	switch op {
	case "location":
		latitude := c.Input().Get("latitude")
		longitude := c.Input().Get("longitude")
		c.Data["latitude"] = latitude
		c.Data["longitude"] = longitude
		beego.Debug("latitude:", latitude)
		beego.Debug("longitude:", longitude)
		getWifi(longitude, latitude, c)
		c.TplName = "zhoubianwifi.html"
		return
	}
	appId := ""
	iniconf, err := config.NewConfig("json", "conf/myconfig.json")
	if err != nil {
		beego.Debug(err)
	} else {
		appId = iniconf.String("qax580::appid")
	}
	timestamp := time.Now().Unix()
	noncestr := getNonceStr(16, KC_RAND_KIND_ALL)
	c.Data["AppId"] = appId
	c.Data["TimesTamp"] = timestamp
	c.Data["NonceStr"] = noncestr
	getWifiWxJsToken(noncestr, timestamp, c)
	c.TplName = "zhoubianwifiwx.html"
	// getWifi("116.366324", "39.905859", c)
	// c.TplName = "zhoubianwifi.html"
}
开发者ID:424626154,项目名称:Qax580_GoServer,代码行数:31,代码来源:zhoubianwifiwx.go


示例13: initDb

func initDb() {
	iniconf, err := config.NewConfig("ini", "conf/app.conf")
	if err != nil {
		beego.Error(err)
	}
	driverName := iniconf.String("orm::driver_name")
	dataSource := iniconf.String("orm::data_source")
	maxIdle, _ := iniconf.Int("orm::max_idle_conn")
	maxOpen, _ := iniconf.Int("orm::max_open_conn")

	// set default database
	err = orm.RegisterDataBase("default", driverName, dataSource, maxIdle, maxOpen)
	if err != nil {
		beego.Error(err)
	}
	//	orm.Debug = true

	//orm.RunCommand()							//执行命令行的

	err = orm.RunSyncdb("default", false, false) //建表的
	////数据库别名,不强制建数据库,打印建表过程

	if err != nil {
		beego.Error(err)
	}
}
开发者ID:oyoy8629,项目名称:hellodb,代码行数:26,代码来源:init.go


示例14: readConfig

func readConfig() {
	jsonconf, err := config.NewConfig("json", "conf/config.json")
	if err != nil {
		panic(err)
	}

	BlogInfo = make(map[string]string)
	BlogInfo["title"] = jsonconf.String("blog::title")
	BlogInfo["subtitle"] = jsonconf.String("blog::subtitle")
	fmt.Println(BlogInfo)

	admin = new(User)
	admin.Email = jsonconf.String("admin::email")
	admin.Username = jsonconf.String("admin::username")
	admin.Password = jsonconf.String("admin::password")
	_, err = c_users.RemoveAll(bson.M{})
	if err != nil {
		panic(err)
	}
	AddUser(admin)

	h := md5.New()
	h.Write([]byte(admin.Email))
	BlogInfo["avatarhash"] = fmt.Sprintf("%x", h.Sum(nil))
}
开发者ID:jmptrader,项目名称:MartianBlog,代码行数:25,代码来源:init.go


示例15: ConnectDB

func ConnectDB(env string) {
	DBconf, err := config.NewConfig("ini", "config/database.conf")

	if err != nil {
		panic(err)
	}

	config, err := DBconf.GetSection(env)

	if err != nil {
		panic(err)
	}

	DB, err = gorm.Open("postgres", "host="+config["host"]+" user="+config["user"]+" dbname="+config["dbname"]+" sslmode=disable")

	if err != nil {
		log.Fatalln(err)
		return
	}

	switch env {
	case "dev":
		// DB.LogMode(true)
	case "test":
		loadFixtures()
	}
}
开发者ID:gymer,项目名称:pusher-api,代码行数:27,代码来源:db.go


示例16: TestGetDockerConf

func TestGetDockerConf(t *testing.T) {
	path := "../testsuite.conf"
	conf, err := config.NewConfig("ini", path)
	if err != nil {
		t.Errorf("Read %s error: %v", path, err.Error())
	}

	if domains := conf.String("test::domains"); domains != "" {
		Domains = domains
	} else {
		t.Errorf("Read %s error: nil", domains)
	}

	if username := conf.String("test::username"); username != "" {
		UserName = username
	} else {
		t.Errorf("Read %s error: nil", username)
	}

	if client := conf.String("test::client"); client != "" {
		DockerBinary = client
	} else {
		t.Errorf("Read %s error: nil", client)
	}
}
开发者ID:CodeJuan,项目名称:dockyard,代码行数:25,代码来源:config_test.go


示例17: createUserDirectory

///////////////////////////////////////////////
// Create user directories, for code files and resources
func (c *SignupController) createUserDirectory(user models.User, group string) {

	// Create project directories
	models.CreateDirectories(beego.AppConfig.String("userdata::location")+user.Name, true)

	// Create .spielplatz files
	dir := beego.AppConfig.String("userdata::location") + user.Name + "/" + beego.AppConfig.String("userdata::spielplatzdir") + "/"
	identityFile := dir + "identity"
	file, err := os.Create(identityFile)
	if err != nil {
		beego.Error(err)
	}
	file.Close()
	cnf, err := config.NewConfig("ini", identityFile)
	if err != nil {
		beego.Error("Cannot create identity file in " + dir + " (" + err.Error() + ")")
	}
	cnf.Set("auth::Pwhash", user.Pwhash)
	cnf.Set("rights::NoSpecialRights", "true")
	cnf.Set("groups::member", group)
	cnf.SaveConfigFile(identityFile)

	// Clone Admin Spielplatz project
	err = models.CloneProjectDir(user.Name, beego.AppConfig.String("userdata::commonproject"), true)
	if err != nil {
		beego.Error(err)
	}
}
开发者ID:lafisrap,项目名称:Computer-Spielplatz,代码行数:30,代码来源:controllers.go


示例18: newConfig

func newConfig() config.ConfigContainer {
	cnf, err := config.NewConfig("yaml", "config.yaml")
	if err != nil {
		panic(err)
	}
	return cnf
}
开发者ID:lincolnlee,项目名称:AsyncCache,代码行数:7,代码来源:confighelper.go


示例19: upgetconfig

func upgetconfig(conffile string) (err error) {
	var conf config.ConfigContainer
	conf, err = config.NewConfig("ini", conffile)
	if err != nil {
		return err
	}

	g_upEndpoint = conf.String("upCloud::endpoint")
	if g_upEndpoint == "" {
		return errors.New("read config file's endpoint failed!")
	}

	g_upBucket = conf.String("upCloud::bucket")
	if g_upBucket == "" {
		return errors.New("read config file's bucket failed!")
	}

	g_upUser = conf.String("upCloud::user")
	if g_upUser == "" {
		return errors.New("read config file's user failed!")
	}

	g_upPasswd = conf.String("upCloud::passwd")
	if g_upPasswd == "" {
		return errors.New("read config file's passwd failed!")

	}
	return nil
}
开发者ID:haoyuist,项目名称:dockyard,代码行数:29,代码来源:upyun.go


示例20: init

func init() {
	err := errors.New("")

	Appconf, err = config.NewConfig("json", "conf/blog.json")
	if err != nil {
		panic(err)
	}

	// fmt.Println(Appconf.Int("database::port"))
	host := Appconf.String("database::host")
	port, _ := Appconf.Int("database::port")
	// fmt.Println(Appconf.DIY("blog::author"))

	db, err = ssdb.Connect(host, port)
	if err != nil {
		panic(err)
	}

	authorsRaw, err := Appconf.DIY("blog::author")
	if err != nil {
		panic(err)
	}
	authors := authorsRaw.([]interface{})
	for _, a := range authors {
		atemp, ok := a.(map[string]interface{})
		if !ok {
			panic(ok)
		}

		author := &Author{}
		author.Name = atemp["name"].(string)
		author.Password = atemp["password"].(string)
		AddAuthor(author.Name, author.Password)
	}
}
开发者ID:jango2015,项目名称:Blog-3,代码行数:35,代码来源:init.go



注:本文中的github.com/astaxie/beego/config.NewConfig函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang config.ConfigContainer类代码示例发布时间:2022-05-24
下一篇:
Golang cache.NewCache函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap