mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
cmd/cloner: add regression test for slice nil/empty semantics
We had a misstep with the semantics when applying an optimization that showed up in the roll into corp. This test ensures that case and related cases must be retained. Updates #9410 Updates #9601 Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:

committed by
James Tucker

parent
e03f0d5f5c
commit
ab810f1f6d
@@ -157,7 +157,11 @@ func (src *StructWithSlices) Clone() *StructWithSlices {
|
||||
if src.Ints != nil {
|
||||
dst.Ints = make([]*int, len(src.Ints))
|
||||
for i := range dst.Ints {
|
||||
dst.Ints[i] = ptr.To(*src.Ints[i])
|
||||
if src.Ints[i] == nil {
|
||||
dst.Ints[i] = nil
|
||||
} else {
|
||||
dst.Ints[i] = ptr.To(*src.Ints[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
dst.Slice = append(src.Slice[:0:0], src.Slice...)
|
||||
|
Reference in New Issue
Block a user