From 939ae5819935e94f8b79362a31631daaa83e2fb0 Mon Sep 17 00:00:00 2001 From: Chris Marchesi Date: Thu, 13 Feb 2020 18:51:40 -0800 Subject: [PATCH] gohcl: document optional attribute This documents the "optional" attribute, which allows you to specify an attribute that is optional when parsing. --- gohcl/doc.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gohcl/doc.go b/gohcl/doc.go index aa3c6ea..c1921cb 100644 --- a/gohcl/doc.go +++ b/gohcl/doc.go @@ -17,6 +17,7 @@ // attr (the default) indicates that the value is to be populated from an attribute // block indicates that the value is to populated from a block // label indicates that the value is to populated from a block label +// optional is the same as attr, but the field is optional // remain indicates that the value is to be populated from the remaining body after populating other fields // // "attr" fields may either be of type *hcl.Expression, in which case the raw @@ -34,6 +35,9 @@ // the blocks being decoded. In this case, the name token is used only as // an identifier for the label in diagnostic messages. // +// "optional" fields behave like "attr" fields, but they are optional +// and will not give parsing errors if they are missing. +// // "remain" can be placed on a single field that may be either of type // hcl.Body or hcl.Attributes, in which case any remaining body content is // placed into this field for delayed processing. If no "remain" field is