]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: simplify code thanks to reflect.Value.SetZero
authorDaniel Martí <mvdan@mvdan.cc>
Sat, 25 Feb 2023 17:24:42 +0000 (17:24 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 27 Feb 2023 15:31:07 +0000 (15:31 +0000)
Change-Id: Ie9c05210390dae43faf566907839bce953925735
Reviewed-on: https://go-review.googlesource.com/c/go/+/471258
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>

src/cmd/go/internal/list/list.go

index ec23024ac880f566af21df2eed714a8e142c30f8..7f3090872b148626efc74ae897fed15fb85c7771 100644 (file)
@@ -446,7 +446,7 @@ func runList(ctx context.Context, cmd *base.Command, args []string) {
                                // Clear all non-requested fields.
                                for i := 0; i < v.NumField(); i++ {
                                        if !listJsonFields.needAny(v.Type().Field(i).Name) {
-                                               v.Field(i).Set(reflect.Zero(v.Type().Field(i).Type))
+                                               v.Field(i).SetZero()
                                        }
                                }
                        }