У меня есть структура
type Products struct {
Name string
Version string
Description string
}
удерживая многострочную строковую константу в качестве значения для поля Description
, константа выглядит следующим образом
const DEFAULT_DESCRIPTION = `Please add the description here without removing the literal block (|)
Sample description will be as follows,
Fixes for the following in rabbitmq transport
(i) Channel not closing issue in rabbitmq publisher
(ii) Performance improvements to the transport by introducing a channel pool (configurable) and parameterising queue and exchange creation.
(iii) Allow configuring connection factory by name in target url`
Затем я использую пакет gopkg.in/yaml.v2
для маршалинга вышеуказанной структуры (которая содержит указанную выше константу в качестве значения для своего поля) следующим образом
data, err = yaml.Marshal(updateDescriptorV3)
и записать сгенерированное содержимое yaml
в файл, используя os.file.Write()
Но в сгенерированном выше файле yaml
после символа literal_block существует -
(|
) Что я делаю не так?
description: |-
Please add the description here without removing the literal block (|)
Sample description will be as follows,
Fixes for the following in rabbitmq transport
(i) Channel not closing issue in rabbitmq publisher
(ii) Performance improvements to the transport by introducing a channel pool (configurable) and parameterising queue and exchange creation.
(iii) Allow configuring connection factory by name in target url
Что нужно сделать, чтобы получить указанную выше константу как литерал_блока в yaml
следующим образом?
description: |
Please add the description here without removing the literal block (|)
Sample description will be as follows,
Fixes for the following in rabbitmq transport
(i) Channel not closing issue in rabbitmq publisher
(ii) Performance improvements to the transport by introducing a channel pool (configurable) and parameterising queue and exchange creation.
(iii) Allow configuring connection factory by name in target url