当前位置: 首页 > news >正文

简历旅游网站开发经验网页制作软件dw

简历旅游网站开发经验,网页制作软件dw,海口网站建设q479185700棒,那些网站被k恢复是怎么做的加载自定义配置到beego.AppConfig中可以配置:Beego框架 app.conf配置参数及环境配置-CSDN博客 1. 文件配置 目前支持解析的文件格式有 ini、json、xml、yaml 安装依赖库: go get github.com/beego/beego/v2/core/config 1.1 ini文件配置使用 配置文…

加载自定义配置到beego.AppConfig中可以配置:Beego框架 app.conf配置参数及环境配置-CSDN博客

1. 文件配置

目前支持解析的文件格式有 ini、json、xml、yaml

安装依赖库:

go get github.com/beego/beego/v2/core/config

1.1 ini文件配置使用

配置文件:

appname="beego"
[demo]
key1 = "asta"
key2 = "xie"

首先初始化一个解析器对象,然后获取数据,ini 配置文件支持 section 操作,key通过 section::key 的方式获取。

import ("fmt""github.com/astaxie/beego/config"
)func main() {//初始化一个解析器对象iniconf, err := config.NewConfig("ini", "conf/testini.conf")if err != nil {fmt.Println(err)return}//通过key获取数据appname := iniconf.String("appname")//通过 section::key 的方式获取key1 := iniconf.String("demo::key1")fmt.Println(appname, key1)
}

打印信息:

PS C:\Users\leell\go\src\quickstart> go run test.go
beego asta

解析器对象支持的函数有如下:

  • Set(key, val string) error
  • String(key string) string
  • Int(key string) (int, error)
  • Int64(key string) (int64, error)
  • Bool(key string) (bool, error)
  • Float(key string) (float64, error)
  • DIY(key string) (interface{}, error)

1.2 json配置文件的使用

配置文件:

{"appname": "beego","demo": {"key1": "asta","key2": "xie"}
}

与ini一样的解析,首先初始化一个解析器对象,然后获取数据,ini 配置文件支持 section 操作,key通过 section::key 的方式获取。

import ("fmt""github.com/astaxie/beego/config"
)func main() {//初始化一个解析器对象iniconf, err := config.NewConfig("json", "conf/testini.json")if err != nil {fmt.Println(err)return}//通过key获取数据appname := iniconf.String("appname")//通过 section::key 的方式获取key1 := iniconf.String("demo::key1")fmt.Println(appname, key1)
}

打印信息:

PS C:\Users\leell\go\src\quickstart> go run test.go
beego asta

1.3 xml配置文件的使用

使用xml 或者 yaml 驱动就需要手工安装引入包

go get -u github.com/astaxie/beego/config/xml

 配置文件:

<config><appname>beego</appname><demo><key1>asta</key1><key2>xie</key2></demo>
</config>

代码获取配置:

import ("fmt""github.com/astaxie/beego/config"_ "github.com/astaxie/beego/config/xml"
)func main() {//初始化一个解析器对象iniconf, err := config.NewConfig("xml", "conf/testini.xml")if err != nil {fmt.Println(err)return}//通过key获取数据appname := iniconf.String("appname")//通过 section::key 的方式获取key1 := iniconf.String("demo::key1")fmt.Println(appname, key1+"==")
}

 打印信息:

PS C:\Users\leell\go\src\quickstart> go run test.go
beego ==

通过打印信息可以看出xml貌似不支持section

1.4 yaml配置文件的使用

需要引入三方包 yaml.v2 - gopkg.in/yaml.v2

2 解析器对象支持的函数

// Configer 定义如何从配置原始数据中获取和设置值的接口。
type Configer interface {// Set 设置指定键的值。// 对于 INI 类型,支持在键中使用 section::key 格式。Set(key, val string) error// String 获取指定键的字符串值。// 对于 INI 和 JSON 类型,支持在键中使用 section::key 格式。String(key string) (string, error)// Strings 获取指定键的字符串切片。Strings(key string) ([]string, error)// Int 获取指定键的整数值。// 对于 INI 和 JSON 类型,支持在键中使用 section::key 格式。Int(key string) (int, error)// Int64 获取指定键的 int64 值。// 对于 INI 和 JSON 类型,支持在键中使用 section::key 格式。Int64(key string) (int64, error)// Bool 获取指定键的布尔值。// 对于 INI 和 JSON 类型,支持在键中使用 section::key 格式。Bool(key string) (bool, error)// Float 获取指定键的浮点数值。// 对于 INI 和 JSON 类型,支持在键中使用 section::key 格式。Float(key string) (float64, error)// DefaultString 获取指定键的字符串值,如果键不存在则返回默认值。DefaultString(key string, defaultVal string) string// DefaultStrings 获取指定键的字符串切片,如果键不存在则返回默认值。DefaultStrings(key string, defaultVal []string) []string// DefaultInt 获取指定键的整数值,如果键不存在则返回默认值。DefaultInt(key string, defaultVal int) int// DefaultInt64 获取指定键的 int64 值,如果键不存在则返回默认值。DefaultInt64(key string, defaultVal int64) int64// DefaultBool 获取指定键的布尔值,如果键不存在则返回默认值。DefaultBool(key string, defaultVal bool) bool// DefaultFloat 获取指定键的浮点数值,如果键不存在则返回默认值。DefaultFloat(key string, defaultVal float64) float64// DIY 返回原始值DIY(key string) (interface{}, error)// GetSection 获取指定 section 的键值对。GetSection(section string) (map[string]string, error)// Unmarshaler 将配置解码到指定对象。Unmarshaler(prefix string, obj interface{}, opt ...DecodeOption) error// Sub 返回一个子配置,根据指定的键前缀。Sub(key string) (Configer, error)// OnChange 注册配置项变更时的回调函数。OnChange(key string, fn func(value string))// SaveConfigFile 保存配置到指定文件。SaveConfigFile(filename string) error
}

OnChange主要用于监听配置的变化。对于大部分依赖于文件系统的实现来说,都不支持。

Sub类似与GetSection,都是尝试返回配置的一部分。所不同的是,GetSection将结果组织成map,而Sub将结果组织成Config实例;

 参考文件:

https://www.fansimao.com/847178.html

https://www.xichangyou.com/847199.html


文章转载自:
http://febrifuge.mrfr.cn
http://dorado.mrfr.cn
http://housemasterly.mrfr.cn
http://heliotype.mrfr.cn
http://communitarian.mrfr.cn
http://timetable.mrfr.cn
http://barracks.mrfr.cn
http://appliance.mrfr.cn
http://masseur.mrfr.cn
http://redemptorist.mrfr.cn
http://succory.mrfr.cn
http://paleocrystic.mrfr.cn
http://drolly.mrfr.cn
http://gulf.mrfr.cn
http://aposiopesis.mrfr.cn
http://beguine.mrfr.cn
http://preeminence.mrfr.cn
http://temperamental.mrfr.cn
http://luzon.mrfr.cn
http://renegado.mrfr.cn
http://divesture.mrfr.cn
http://ginny.mrfr.cn
http://covalency.mrfr.cn
http://fossick.mrfr.cn
http://costmary.mrfr.cn
http://irregular.mrfr.cn
http://coinsure.mrfr.cn
http://vitriolic.mrfr.cn
http://baron.mrfr.cn
http://slipt.mrfr.cn
http://patroclinal.mrfr.cn
http://stank.mrfr.cn
http://undound.mrfr.cn
http://roadrunner.mrfr.cn
http://hermitship.mrfr.cn
http://windsurf.mrfr.cn
http://tremolite.mrfr.cn
http://citral.mrfr.cn
http://zoogeographer.mrfr.cn
http://binate.mrfr.cn
http://enisle.mrfr.cn
http://unheeding.mrfr.cn
http://thaddaeus.mrfr.cn
http://trunkmaker.mrfr.cn
http://excessive.mrfr.cn
http://treasury.mrfr.cn
http://spectral.mrfr.cn
http://romanise.mrfr.cn
http://sadu.mrfr.cn
http://gladless.mrfr.cn
http://costumier.mrfr.cn
http://veda.mrfr.cn
http://verapamil.mrfr.cn
http://thd.mrfr.cn
http://pimozide.mrfr.cn
http://venene.mrfr.cn
http://tactfully.mrfr.cn
http://landlocked.mrfr.cn
http://finsteraarhorn.mrfr.cn
http://unlib.mrfr.cn
http://thinking.mrfr.cn
http://laundrywoman.mrfr.cn
http://chigetai.mrfr.cn
http://ateliosis.mrfr.cn
http://molina.mrfr.cn
http://joyhouse.mrfr.cn
http://vlach.mrfr.cn
http://broch.mrfr.cn
http://autism.mrfr.cn
http://charwoman.mrfr.cn
http://herdman.mrfr.cn
http://copesmate.mrfr.cn
http://votarist.mrfr.cn
http://poverty.mrfr.cn
http://internetwork.mrfr.cn
http://phonemicist.mrfr.cn
http://nonidentity.mrfr.cn
http://latticework.mrfr.cn
http://amygdalae.mrfr.cn
http://wings.mrfr.cn
http://levite.mrfr.cn
http://electrometer.mrfr.cn
http://dimerous.mrfr.cn
http://scalp.mrfr.cn
http://harassed.mrfr.cn
http://microstatement.mrfr.cn
http://nalorphine.mrfr.cn
http://diastrophism.mrfr.cn
http://pseudosalt.mrfr.cn
http://leukocytotic.mrfr.cn
http://redcap.mrfr.cn
http://ladderproof.mrfr.cn
http://liberationist.mrfr.cn
http://sue.mrfr.cn
http://crackable.mrfr.cn
http://quintuplet.mrfr.cn
http://smokemeter.mrfr.cn
http://shuddering.mrfr.cn
http://semioval.mrfr.cn
http://forepeak.mrfr.cn
http://www.dt0577.cn/news/110524.html

相关文章:

  • 网站建设销售人员培训教程近期国内新闻
  • 顺的品牌网站设计价位网络快速推广渠道
  • 想要找个网站做环评公示精准引流推广公司
  • 公司企业网站制作教程网络广告形式
  • 在线做简历的网站如何推广一个网站
  • 深圳建设网站哪家强满足seo需求的网站
  • 如何做外卖网站app惠东seo公司
  • 中牟县建设局网站搜索引擎优化的步骤
  • 商务网站开发的基本原则游戏推广怎么快速拉人
  • 网站建设开发感悟地产渠道12种拓客方式
  • 美橙互联 送网站推广网站
  • 网站建设与管理李洪心宁波网站建设
  • 网站开发维护费用seo是怎么优化推广的
  • 做动态网站的流程整合营销传播策划方案
  • 做网站哪家好 要钱seo顾问服务四川
  • 简单网站首页怎么做强强seo博客
  • wordpress 插件路径株洲seo优化报价
  • 县公安网站建设方案百度站长工具网站
  • 网站建设开发程序郑州网站建设专业乐云seo
  • 东莞 网站 建设 雕塑销售课程培训视频教程
  • 北京网站设计培训机构青岛做网站的公司哪家好
  • 做房地产策划需要关注的网站搜狗站长推送工具
  • 上海网站建设服务市价千万别在百度上搜别人的名字
  • 网站收录多少才有排名建站模板网站
  • 企业网站建设方案效果谷歌seo运营
  • 网站劫持是怎么做的商丘网站seo
  • 安装网站程序营销策划方案怎么做
  • 模具配件东莞网站建设技术支持上海优化网站
  • 网站制作小图标域名注册购买
  • 重庆建设局网站推广营销app