docs(engine): fix misleading toTOML doc comment

The toTOML doc comment said "returns empty string on marshal error"
but the implementation actually returns err.Error(). Fix the comment
to match the real behavior. Also mention mustToToml as the strict
alternative.

Signed-off-by: Ilya Kiselev <kis-ilya-a@yandex.ru>
pull/31957/head
Ilya Kiselev 4 weeks ago
parent b075f7a35d
commit c1a5a6e260

@ -149,10 +149,11 @@ func fromYAMLArray(str string) []any {
return a
}
// toTOML takes an interface, marshals it to toml, and returns a string. It will
// always return a string, even on marshal error (empty string).
// toTOML takes an interface, marshals it to toml, and returns a string.
// On marshal error it returns the error string.
//
// This is designed to be called from a template.
// This is designed to be called from a template. Use mustToToml if you need
// the template to fail hard on marshal errors.
func toTOML(v any) string {
b := bytes.NewBuffer(nil)
e := toml.NewEncoder(b)

Loading…
Cancel
Save