You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2021/04/14 13:21:00 UTC

[plc4x] 10/14: plc4go: set arrays to nil if empty on parse in generated code

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 3614f4d6d8fccd4b4be931c81719ebf9beb89476
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Apr 14 13:24:22 2021 +0200

    plc4go: set arrays to nil if empty on parse in generated code
---
 .../language-go/src/main/resources/templates/go/model-template.go.ftlh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/build-utils/language-go/src/main/resources/templates/go/model-template.go.ftlh b/build-utils/language-go/src/main/resources/templates/go/model-template.go.ftlh
index f7f19a4..2a43830 100644
--- a/build-utils/language-go/src/main/resources/templates/go/model-template.go.ftlh
+++ b/build-utils/language-go/src/main/resources/templates/go/model-template.go.ftlh
@@ -427,6 +427,9 @@ func ${type.name}Parse(io *utils.ReadBuffer<#if type.parserArguments?has_content
 					</#if>
 	}
 				</#if>
+	if len(${arrayField.name}) == 0 {
+		${arrayField.name} = nil
+	}
 				<#break>
 			<#case "checksum">
 				<#assign checksumField = field>