cmd/cloner: fix typo in test type's name

s/SliceContianer/SliceContainer/g

Updates #9604

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/9609/head
Brad Fitzpatrick 8 months ago committed by Brad Fitzpatrick
parent ab810f1f6d
commit d2ea9bb1eb

@ -13,7 +13,7 @@ func TestSliceContainer(t *testing.T) {
num := 5 num := 5
examples := []struct { examples := []struct {
name string name string
in *clonerex.SliceContianer in *clonerex.SliceContainer
}{ }{
{ {
name: "nil", name: "nil",
@ -21,29 +21,29 @@ func TestSliceContainer(t *testing.T) {
}, },
{ {
name: "zero", name: "zero",
in: &clonerex.SliceContianer{}, in: &clonerex.SliceContainer{},
}, },
{ {
name: "empty", name: "empty",
in: &clonerex.SliceContianer{ in: &clonerex.SliceContainer{
Slice: []*int{}, Slice: []*int{},
}, },
}, },
{ {
name: "nils", name: "nils",
in: &clonerex.SliceContianer{ in: &clonerex.SliceContainer{
Slice: []*int{nil, nil, nil, nil, nil}, Slice: []*int{nil, nil, nil, nil, nil},
}, },
}, },
{ {
name: "one", name: "one",
in: &clonerex.SliceContianer{ in: &clonerex.SliceContainer{
Slice: []*int{&num}, Slice: []*int{&num},
}, },
}, },
{ {
name: "several", name: "several",
in: &clonerex.SliceContianer{ in: &clonerex.SliceContainer{
Slice: []*int{&num, &num, &num, &num, &num}, Slice: []*int{&num, &num, &num, &num, &num},
}, },
}, },

@ -1,10 +1,10 @@
// Copyright (c) Tailscale Inc & AUTHORS // Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
//go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type SliceContianer //go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type SliceContainer
package clonerex package clonerex
type SliceContianer struct { type SliceContainer struct {
Slice []*int Slice []*int
} }

@ -9,13 +9,13 @@ import (
"tailscale.com/types/ptr" "tailscale.com/types/ptr"
) )
// Clone makes a deep copy of SliceContianer. // Clone makes a deep copy of SliceContainer.
// The result aliases no memory with the original. // The result aliases no memory with the original.
func (src *SliceContianer) Clone() *SliceContianer { func (src *SliceContainer) Clone() *SliceContainer {
if src == nil { if src == nil {
return nil return nil
} }
dst := new(SliceContianer) dst := new(SliceContainer)
*dst = *src *dst = *src
if src.Slice != nil { if src.Slice != nil {
dst.Slice = make([]*int, len(src.Slice)) dst.Slice = make([]*int, len(src.Slice))
@ -31,21 +31,21 @@ func (src *SliceContianer) Clone() *SliceContianer {
} }
// A compilation failure here means this code must be regenerated, with the command at the top of this file. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _SliceContianerCloneNeedsRegeneration = SliceContianer(struct { var _SliceContainerCloneNeedsRegeneration = SliceContainer(struct {
Slice []*int Slice []*int
}{}) }{})
// Clone duplicates src into dst and reports whether it succeeded. // Clone duplicates src into dst and reports whether it succeeded.
// To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>, // To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
// where T is one of SliceContianer. // where T is one of SliceContainer.
func Clone(dst, src any) bool { func Clone(dst, src any) bool {
switch src := src.(type) { switch src := src.(type) {
case *SliceContianer: case *SliceContainer:
switch dst := dst.(type) { switch dst := dst.(type) {
case *SliceContianer: case *SliceContainer:
*dst = *src.Clone() *dst = *src.Clone()
return true return true
case **SliceContianer: case **SliceContainer:
*dst = src.Clone() *dst = src.Clone()
return true return true
} }

Loading…
Cancel
Save