We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
flow
1.19.0
1.23.1
Manual set
YAML
No response
package main import ( "github.com/spf13/viper" ) type Something struct { Id int `yaml:"Id,flow"` Name string `yaml:"Name,flow"` } func main() { s := []Something{{Id: 1, Name: "Foo"}, {Id: 2, Name: "Bar"}, {Id: 3, Name: "Baz"}} viper.Set("something", s) if err := viper.WriteConfigAs("config.yaml"); err != nil { panic(err) } }
I thought config.yaml would be written like this:
config.yaml
something: - id: 1 name: Foo - id: 2 name: Bar - id: 3 name: Baz
But it was actually written as follows:
something: - Id: 1 Name: Foo - {Id: 2, Name: Bar} - {Id: 3, Name: Baz}
When untagged it worked as expected.
main.go
package main import ( "github.com/spf13/viper" ) type Something struct { Id int Name string } func main() { s := []Something{{Id: 1, Name: "Foo"}, {Id: 2, Name: "Bar"}, {Id: 3, Name: "Baz"}} viper.Set("something", s) if err := viper.WriteConfigAs("config.yaml"); err != nil { panic(err) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Preflight Checklist
Viper Version
1.19.0
Go Version
1.23.1
Config Source
Manual set
Format
YAML
Repl.it link
No response
Code reproducing the issue
Expected Behavior
I thought
config.yaml
would be written like this:Actual Behavior
But it was actually written as follows:
Steps To Reproduce
No response
Additional Information
When untagged it worked as expected.
main.go
config.yaml
The text was updated successfully, but these errors were encountered: