You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "zeroshade (via GitHub)" <gi...@apache.org> on 2023/06/01 15:17:11 UTC

[GitHub] [arrow] zeroshade commented on a diff in pull request #35867: GH-35866: [Go] Provide a copy in `arrow.NestedType.Fields()` implementations

zeroshade commented on code in PR #35867:
URL: https://github.com/apache/arrow/pull/35867#discussion_r1213315826


##########
go/arrow/datatype_nested.go:
##########
@@ -490,7 +495,12 @@ func (t *unionType) init(fields []Field, typeCodes []UnionTypeCode) {
 	}
 }
 
-func (t unionType) Fields() []Field            { return t.children }
+func (t unionType) Fields() []Field {
+	fields := make([]Field, len(t.children))
+	copy(fields, t.children)
+	return fields
+}

Review Comment:
   same here. add a godoc comment to this to indicate it makes a copy of the fields



##########
go/arrow/datatype_nested.go:
##########
@@ -288,7 +288,12 @@ func (t *StructType) String() string {
 	return o.String()
 }
 
-func (t *StructType) Fields() []Field   { return t.fields }
+func (t *StructType) Fields() []Field {

Review Comment:
   Can you add a godoc comment on the methods to indicate to callers that this will make a copy of the Fields?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org