草庐IT

go - 使用键解析 yaml 提供错误

我有以下需要解析的yaml,我试过以下Build-t:before:test1-value:dddd-bbb:zzzzafter:test2-value:bbb-aaa:aaaa我试过以下方法:typerootstruct{buildtypeBuild`yaml:"Build-t,omitempty"`}typeBuildstruct{Beforemap[string]interface{}`yaml:"before,omitempty"`Aftermap[string]interface{}`yaml:"after,omitempty"`}现在当我解析它时出现错误,我需要的是从对象b

go - 在 Golang 中找出正确的结构来解析一个简单的 YAML 文件

我有一个相当简单的YAML文档来解析成Go中的(最好)map。YAML文档:---A:Logon'0':Heartbeat'1':TestRequest'2':ResendRequest'3':Reject'4':SequenceReset'5':Logout'8':ExecutionReportS:QuoteAE:TradeCaptureReportB:Newsh:TradingSessionStatusf:SecurityStatus我正在尝试将其编码typeTranslationValstruct{Mapmap[string]string}translationVal:=Tran

dictionary - 构造深层结构不起作用

我有一个负责从yaml文件中解析数据的结构虽然这个结构在工作,但有时我会得到一些我需要解析的新字段这是有效的-name:test1type:typepath:path这不是-name:test1type:typepath:pathbuild-parameters:maven-opts:defines:skipTests:true这是结构typeModulesstruct{NamestringTypestringPathstringParametersParameters`yaml:"build-parameters,omitempty"`}参数的类型是:typeParametersma

go - 从 yaml 文件中以自定义格式读取配置

我有一个YAML格式的配置文件。我正在尝试以某种自定义格式读取配置。我猜不出我可以使用的任何模式,比如树、json等。例如。应用程序.yamlorganization:products:product1:manager:"Rob"engineer:"John"product2:manager:"Henry"lead:"patrick"配置文件可能包含大量信息,并且因文件而异。我想按以下格式构造数据,organization/products/product1/manager=Roborganization/products/product1/engineer=Johnorganizat

validation - Kubernetes client-go 库是否包含用于验证 json/yaml 文件的功能?

我想知道Kubernetes的client-go库是否包含一个函数来验证json/yaml文件。理想情况下,它会捕获错误,例如名称不符合DNS-1123标准或指定的字段无效。如果返回错误列表而不是函数在遇到第一个错误后返回,这也是理想的。我试过的一个想法是执行一个exec来调用kubectl--validate--dry-run但这并不能完全验证list(这意味着它可以通过这里但在你实际执行时失败应用文件)。它也会在第一个错误处停止。另外,如果您要查看list列表,成本会很快变高。我查看的另一个选项在这里KubernetesGitHubIssue193但这并不是真正合适的功能,也不会执

go - 尝试将 yaml 数据转换为结构时输出为空

这个问题在这里已经有了答案:GoUnmarshalingYAMLintostruct(2个答案)关闭4年前。我正在尝试将yaml数据转换为结构并打印它。我得到的这个程序的输出是空的。packagemainimport("fmt""gopkg.in/yaml.v2")typeexamplestruct{variable1stringvariable2string}funcmain(){varaexampleyaml.Unmarshal([]byte("variable1:asd\nvariable2:sdcs"),&a)fmt.Println(a.variable1)}

go - 解析 yaml 结构错误

我有以下yaml,当我尝试解析它时出现错误,知道这里可能遗漏了什么吗?我不确定如何构造区域属性。T他是有效的yamlhttps://codebeautify.org/yaml-validator/cb42f23a错误:errorinmodelextConfigYaml:*yaml:line4:mappingvaluesarenotallowedinthiscontexttypeExternalConfigstruct{Landscapezone`yaml:"Landscape"`}typezonestruct{zonemodels`yaml:"zone"`}typemodelsstru

go - 我们可以参数化 glide.yaml 文件吗?

这是官方文档中的glide.yaml文件package:github.com/Masterminds/glidehomepage:https://masterminds.github.io/glidelicense:MITowners:-name:MattButcheremail:technosophos@gmail.comhomepage:http://technosophos.com-name:MattFarinaemail:matt@mattfarina.comhomepage:https://www.mattfarina.comignore:-appengineexcludeD

go - 如何创建用 golang sciter 库编写的程序的 snap YAML 文件?

你能帮帮我吗?如何为使用名为golang和sciter库的语言编写的golang应用程序创建YAML文件https://sciter.com/?我的意思是如何将内容写入yaml文件以使snapcraft商店的snap正常工作?感谢您的任何建议。packagemainimport("log""github.com/sciter-sdk/go-sciter""github.com/sciter-sdk/go-sciter/window")funcmain(){w,err:=window.New(sciter.SW_TITLEBAR|sciter.SW_RESIZEABLE|sciter.S

go - Viper 在解码时不考虑我的结构中的 yaml 标签

当我使用viper的Unmarshal方法用我的yaml文件中的值填充我的配置结构时,一些结构字段变成了空!我是这样做的:viper.SetConfigType("yaml")viper.SetConfigName("config")viper.AddConfigPath("/etc/myapp/")viper.AddConfigPath(".")err:=viper.ReadInConfig()//errorchecking...conf:=&ConfYaml{}err=viper.Unmarshal(conf)//errorchecking...我的结构是这样的:typeConfY