草庐IT

normalize_yaml_input

全部标签

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

go - 是否可以将 Go Task runner 配置为使用文件扩展名 yaml?

是否可以配置Go任务运行器(https://taskfile.dev/)以使用文件扩展名为“yaml”而不是“yml”的文件? 最佳答案 任务作者在这里。目前唯一的方法是运行:task--taskfile=Taskfile.yaml或task-tTaskfile.yaml也就是说,有一个openissue和一个openPR关于使.yaml扩展自动工作,因此最终将在没有标志的情况下工作。 关于go-是否可以将GoTaskrunner配置为使用文件扩展名yaml?,我们在StackOverf

postgresql - pq : invalid input syntax for type double precision: "$1" with Golang

我正在尝试在我的GO程序中将一个简单的INSERT插入到postgresql数据库中。我的数字0是一个float64,我的数据库中有一列需要doubleprecision。我不知道我需要将数字转换成什么才能让数据库接受该值。 最佳答案 PostgreSQL驱动程序可以很好地处理将float64插入到double列中:tmp=#\dtestTable"public.test"Column|Type|Modifiers--------+------------------+-----------v|doubleprecision|和代码

golang 解析 yaml 文件结构受到挑战

解析此类yaml文件时遇到问题。使用"yaml.v2"info:"abc"data:source:http://intradestination:/tmprun:-id:"A1"exe:"run.a1"output:"output.A1"-id:"A2"exe:"run.a2"output:"output.A2"我想获取YAML文件的所有值,所以我有一个像这样的基本结构typeConfigstruct{InfostringDatastruct{Sourcestring`yaml:"source"`Destinationstring`yaml:"destination"`}}这行得通但是

go - 在 golang 中解析 yaml 时出错

我有一个像下面这样的yaml,我需要使用go来解析它。当我尝试使用解析运行代码时出现错误。下面是代码:varrunContent=[]byte(`-runners:-name:function1type:func1-command:spawnchildprocess-command:build-command:gulp-name:function1type:func2-command:runfunction1-name:function3type:func3-command:rubybuild-name:function4type:func4-command:gobuild`)这些是类

转到 "unexpected end of JSON input"错误

我知道这个问题已被问过几次,但我没有看到符合我支持NULL值的需求的问题。我有数据库中可选的字段。我需要以JSON格式输出数据,其中包括这些可能为NULL的字段,如果它们仍然为NULL,我想从JSON中忽略这些字段。我可以更改为NULL以外的其他默认值,但我还没有找到一个有效的值。我在MariaDB中以JSON格式(长文本)存储JSON数组。这是我失败的代码(Playgroundlink):packagemainimport("encoding/json""fmt")varrespBytes=[]byte("")//Exampledata[12345,23456,34567]funcm