I can't figure out how to use a multi-line string as part of a yaml sequence:
foo: - bar - bar2 - > super duper long string that I would like to have on multiple lines - Another item
Is it possible?
Raw StringsThey can span multiple lines without concatenation and they don't use escaped sequences. You can use backslashes or double quotes directly.
Creating a multiline string in Go is actually incredibly easy. Simply use the backtick ( ` ) character when declaring or assigning your string value. str := `This is a multiline string.
By default, line breaks are replaced by space characters for consecutive non-empty lines: String key = parseYamlKey("folded. yaml", "key"); assertEquals("Line1 Line2 Line3", key);
Use | if you want those linebreaks to be preserved as \n (for instance, embedded markdown with paragraphs).
If you want to use a folded scalar:
foo: - bar - bar2 - > super duper long string that I would like to have on multiple lines - Another item
Note that there may not be content on the line of the folded scalar's header (the line with the >
).
Alternatively, you can just use a plain scalar:
foo: - bar - bar2 - super duper long string that I would like to have on multiple lines - Another item
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With