Parsing 如何在golang yaml解析器中保留空格和换行符?
我想要像这样的东西 Some text here, indented text here next indented texr hereParsing 如何在golang yaml解析器中保留空格和换行符?,parsing,go,yaml,Parsing,Go,Yaml,我想要像这样的东西 Some text here, indented text here next indented texr here 我不确定您使用哪种解析器来解析YAML,但我使用了一个非常好的代码片段 testviber.yaml invoice: 34843 date : 2001-01-23 abc: | There once was a short man from Ealing Who got on a bus to Darjeeling
我不确定您使用哪种解析器来解析YAML,但我使用了一个非常好的代码片段 testviber.yaml
invoice: 34843
date : 2001-01-23
abc: |
There once was a short man from Ealing
Who got on a bus to Darjeeling
It said on the door
"Please don't spit on the floor"
So he carefully spat on the ceiling
last_invoice: 34843
testviber.go
package main
import (
"fmt"
"github.com/spf13/viper"
)
func main() {
viper.SetConfigName("testviber")
viper.ReadInConfig()
fmt.Printf("%v", viper.Get("abc"))
}
请向我们展示您的Go代码如何解析yaml文件。
invoice: 34843
date : 2001-01-23
abc: |
There once was a short man from Ealing
Who got on a bus to Darjeeling
It said on the door
"Please don't spit on the floor"
So he carefully spat on the ceiling
last_invoice: 34843
package main
import (
"fmt"
"github.com/spf13/viper"
)
func main() {
viper.SetConfigName("testviber")
viper.ReadInConfig()
fmt.Printf("%v", viper.Get("abc"))
}