summaryrefslogtreecommitdiffhomepage
path: root/cmd/cloner/clonerex/clonerex.go
blob: 6463f91442a32e9e0f3c44c7d37f2f9f49a6ee6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause

//go:generate go run tailscale.com/cmd/cloner  -clonefunc=true -type SliceContainer,InterfaceContainer

// Package clonerex is an example package for the cloner tool.
package clonerex

type SliceContainer struct {
	Slice []*int
}

// Cloneable is an interface with a Clone method.
type Cloneable interface {
	Clone() Cloneable
}

// CloneableImpl is a concrete type that implements Cloneable.
type CloneableImpl struct {
	Value int
}

func (c *CloneableImpl) Clone() Cloneable {
	if c == nil {
		return nil
	}
	return &CloneableImpl{Value: c.Value}
}

// InterfaceContainer has a pointer to an interface field, which tests
// the special handling for interface types in the cloner.
type InterfaceContainer struct {
	Interface Cloneable
}