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

Golang gof.Config类代码示例

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

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



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

示例1: initTemplate

func initTemplate(c *gof.Config) *gof.Template {
	return &gof.Template{
		Init: func(m *gof.TemplateDataMap) {
			v := *m
			v["static_serve"] = c.GetString(variable.StaticServer)
			v["img_serve"] = c.GetString(variable.ImageServer)
			v["domain"] = c.GetString(variable.ServerDomain)
			v["version"] = c.GetString(variable.Version)
		},
	}
}
开发者ID:jackyan,项目名称:go2o,代码行数:11,代码来源:context_load.go


示例2: initTemplate

func initTemplate(c *gof.Config) *gof.Template {
	spam := crypto.Md5([]byte(strconv.Itoa(int(time.Now().Unix()))))[8:14]
	return &gof.Template{
		Init: func(m *gof.TemplateDataMap) {
			v := *m
			v["static_serve"] = c.GetString(variable.StaticServer)
			v["img_serve"] = c.GetString(variable.ImageServer)
			v["domain"] = c.GetString(variable.ServerDomain)
			v["version"] = c.GetString(variable.Version)
			v["spam"] = spam
		},
	}
}
开发者ID:yonglehou,项目名称:go2o,代码行数:13,代码来源:context_load.go


示例3: getDb

func getDb(c *gof.Config, debug bool, l log.ILogger) db.Connector {
	//数据库连接字符串
	//[email protected](127.0.0.1:3306)/db_name?charset=utf8
	var connStr string
	driver := c.GetString(variable.DbDriver)
	dbCharset := c.GetString(variable.DbCharset)
	if dbCharset == "" {
		dbCharset = "utf8"
	}
	connStr = fmt.Sprintf("%s:%[email protected](%s:%s)/%s?charset=%s&loc=Local",
		c.GetString(variable.DbUsr),
		c.GetString(variable.DbPwd),
		c.GetString(variable.DbServer),
		c.GetString(variable.DbPort),
		c.GetString(variable.DbName),
		dbCharset,
	)
	connector := db.NewSimpleConnector(driver, connStr, l, 5000, debug)
	OrmMapping(connector)
	return connector
}
开发者ID:yonglehou,项目名称:go2o,代码行数:21,代码来源:context_load.go


示例4: getDb

func getDb(c *gof.Config, debug bool, l log.ILogger) db.Connector {
	//数据库连接字符串
	//[email protected](127.0.0.1:3306)/db_name?charset=utf8
	var connStr string
	driver := c.GetString(variable.DbDriver)
	dbCharset := c.GetString(variable.DbCharset)
	if dbCharset == "" {
		dbCharset = "utf8"
	}
	connStr = fmt.Sprintf("%s:%[email protected](%s:%s)/%s?charset=%s&loc=Local",
		c.GetString(variable.DbUsr),
		c.GetString(variable.DbPwd),
		c.GetString(variable.DbServer),
		c.GetString(variable.DbPort),
		c.GetString(variable.DbName),
		dbCharset,
	)
	connector := db.NewSimpleConnector(driver, connStr, l, 5000, debug)

	//table mapping
	orm := connector.GetOrm()

	/** new **/
	orm.CreateTableMap(member.ValueMember{}, "mm_member")
	orm.CreateTableMap(member.IntegralLog{}, "mm_integral_log")
	orm.CreateTableMap(member.AccountValue{}, "mm_account")
	orm.CreateTableMap(member.DeliverAddress{}, "mm_deliver_addr")
	orm.CreateTableMap(member.MemberRelation{}, "mm_relation")
	orm.CreateTableMap(member.BalanceInfoValue{}, "mm_balance_info")

	orm.CreateTableMap(member.BankInfo{}, "mm_bank")
	orm.CreateTableMap(shopping.ValueOrder{}, "pt_order")
	orm.CreateTableMap(shopping.OrderItem{}, "pt_order_item")
	orm.CreateTableMap(shopping.OrderCoupon{}, "pt_order_coupon")
	orm.CreateTableMap(shopping.OrderPromotionBind{}, "pt_order_pb")
	orm.CreateTableMap(shopping.OrderLog{}, "pt_order_log")
	orm.CreateTableMap(shopping.ValueCart{}, "sale_cart")
	orm.CreateTableMap(shopping.ValueCartItem{}, "sale_cart_item")

	/** 销售 **/
	orm.CreateTableMap(sale.ValueItem{}, "gs_item")
	orm.CreateTableMap(sale.ValueGoods{}, "gs_goods")
	orm.CreateTableMap(sale.ValueCategory{}, "gs_category")
	orm.CreateTableMap(sale.GoodsSnapshot{}, "gs_snapshot")
	orm.CreateTableMap(sale.ValueSaleTag{}, "gs_sale_tag")
	orm.CreateTableMap(sale.MemberPrice{}, "gs_member_price")

	/** 商户 **/
	orm.CreateTableMap(partner.ValuePartner{}, "pt_partner")
	orm.CreateTableMap(partner.ApiInfo{}, "pt_api")
	orm.CreateTableMap(partner.SiteConf{}, "pt_siteconf")
	orm.CreateTableMap(partner.ValueShop{}, "pt_shop")
	orm.CreateTableMap(partner.SaleConf{}, "pt_saleconf")
	orm.CreateTableMap(valueobject.MemberLevel{}, "pt_member_level")
	orm.CreateTableMap(content.ValuePage{}, "pt_page")
	orm.CreateTableMap(ad.ValueAdvertisement{}, "pt_ad")
	orm.CreateTableMap(ad.ValueImage{}, "pt_ad_image")
	orm.CreateTableMap(mss.MailTemplate{}, "pt_mail_template")
	orm.CreateTableMap(mss.MailTask{}, "pt_mail_queue")

	/** 促销 **/
	orm.CreateTableMap(promotion.ValueCoupon{}, "pm_coupon")
	orm.CreateTableMap(promotion.ValueCouponBind{}, "pm_coupon_bind")
	orm.CreateTableMap(promotion.ValueCouponTake{}, "pm_coupon_take")
	orm.CreateTableMap(promotion.ValuePromotion{}, "pm_info")
	orm.CreateTableMap(promotion.ValueCashBack{}, "pm_cash_back")

	/** 配送 **/
	orm.CreateTableMap(delivery.AreaValue{}, "dlv_area")
	orm.CreateTableMap(delivery.CoverageValue{}, "dlv_coverage")
	orm.CreateTableMap(delivery.PartnerDeliverBind{}, "dlv_partner_bind")

	/** 用户 **/
	orm.CreateTableMap(user.RoleValue{}, "usr_role")
	orm.CreateTableMap(user.PersonValue{}, "usr_person")
	orm.CreateTableMap(user.CredentialValue{}, "usr_credential")

	orm.CreateTableMap(valueobject.Goods{}, "")

	return connector
}
开发者ID:zoe527,项目名称:go2o,代码行数:81,代码来源:context_load.go


示例5: createRedisPool

func createRedisPool(c *gof.Config) *redis.Pool {
	redisHost := c.GetString("redis_host")
	redisDb := c.GetString("redis_db")
	redisPort := c.GetInt("redis_port")
	redisAuth := c.GetString("redis_auth")

	if redisPort <= 0 {
		redisPort = 6379
	}
	redisMaxIdle := c.GetInt("redis_maxIdle")
	if redisMaxIdle <= 0 {
		redisMaxIdle = 10000
	}
	redisIdleTimeout := c.GetInt("redis_idleTimeout")
	if redisIdleTimeout <= 0 {
		redisIdleTimeout = 20000
	}

	return &redis.Pool{
		MaxIdle:     redisMaxIdle,
		IdleTimeout: time.Duration(redisIdleTimeout) * time.Second,
		Dial: func() (redis.Conn, error) {
		dial:
			c, err := redis.Dial("tcp", fmt.Sprintf("%s:%d", redisHost, redisPort))
			if err != nil {
				for {
					log.Printf("[ Redis] - redis(%s:%d) dial failed - %s , Redial after 5 seconds\n",
						redisHost, redisPort, err.Error())
					time.Sleep(time.Second * 5)
					goto dial
				}
			}

			if len(redisAuth) != 0 {
				if _, err := c.Do("AUTH", redisAuth); err != nil {
					c.Close()
					log.Fatalf("[ Redis][ AUTH] - %s\n", err.Error())
				}
			}
			if _, err = c.Do("SELECT", redisDb); err != nil {
				c.Close()
				log.Fatalf("[ Redis][ SELECT] - redis(%s:%d) select db failed - %s",
					redisHost, redisPort, err.Error())
			}

			return c, err
		},
		TestOnBorrow: func(c redis.Conn, t time.Time) error {
			_, err := c.Do("PING")
			return err
		},
	}
}
开发者ID:zoe527,项目名称:go2o,代码行数:53,代码来源:redis.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang gof.Message类代码示例发布时间:2022-05-23
下一篇:
Golang gof.App类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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