mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 23:07:44 +00:00
cmd/cloner: fix typo in test type's name
s/SliceContianer/SliceContainer/g Updates #9604 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
ab810f1f6d
commit
d2ea9bb1eb
@ -13,7 +13,7 @@ func TestSliceContainer(t *testing.T) {
|
||||
num := 5
|
||||
examples := []struct {
|
||||
name string
|
||||
in *clonerex.SliceContianer
|
||||
in *clonerex.SliceContainer
|
||||
}{
|
||||
{
|
||||
name: "nil",
|
||||
@ -21,29 +21,29 @@ func TestSliceContainer(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "zero",
|
||||
in: &clonerex.SliceContianer{},
|
||||
in: &clonerex.SliceContainer{},
|
||||
},
|
||||
{
|
||||
name: "empty",
|
||||
in: &clonerex.SliceContianer{
|
||||
in: &clonerex.SliceContainer{
|
||||
Slice: []*int{},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "nils",
|
||||
in: &clonerex.SliceContianer{
|
||||
in: &clonerex.SliceContainer{
|
||||
Slice: []*int{nil, nil, nil, nil, nil},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "one",
|
||||
in: &clonerex.SliceContianer{
|
||||
in: &clonerex.SliceContainer{
|
||||
Slice: []*int{&num},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "several",
|
||||
in: &clonerex.SliceContianer{
|
||||
in: &clonerex.SliceContainer{
|
||||
Slice: []*int{&num, &num, &num, &num, &num},
|
||||
},
|
||||
},
|
||||
|
@ -1,10 +1,10 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// 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
|
||||
|
||||
type SliceContianer struct {
|
||||
type SliceContainer struct {
|
||||
Slice []*int
|
||||
}
|
||||
|
@ -9,13 +9,13 @@
|
||||
"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.
|
||||
func (src *SliceContianer) Clone() *SliceContianer {
|
||||
func (src *SliceContainer) Clone() *SliceContainer {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
dst := new(SliceContianer)
|
||||
dst := new(SliceContainer)
|
||||
*dst = *src
|
||||
if src.Slice != nil {
|
||||
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.
|
||||
var _SliceContianerCloneNeedsRegeneration = SliceContianer(struct {
|
||||
var _SliceContainerCloneNeedsRegeneration = SliceContainer(struct {
|
||||
Slice []*int
|
||||
}{})
|
||||
|
||||
// Clone duplicates src into dst and reports whether it succeeded.
|
||||
// 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 {
|
||||
switch src := src.(type) {
|
||||
case *SliceContianer:
|
||||
case *SliceContainer:
|
||||
switch dst := dst.(type) {
|
||||
case *SliceContianer:
|
||||
case *SliceContainer:
|
||||
*dst = *src.Clone()
|
||||
return true
|
||||
case **SliceContianer:
|
||||
case **SliceContainer:
|
||||
*dst = src.Clone()
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user