tailscale.comtailscale.com/cmd/viewer/tests Index | Files

package tests

import "tailscale.com/cmd/viewer/tests"

Package tests serves a list of tests for tailscale.com/cmd/viewer.

Index

Types

type BasicType

type BasicType interface {
	~bool | constraints.Integer | constraints.Float | constraints.Complex | ~string
}

type Container

type Container[T any] struct {
	Item T
}

Container is a pre-defined container type, such as a collection, an optional value or a generic wrapper.

func (*Container[T]) Clone

func (c *Container[T]) Clone() *Container[T]

type ContainerView

type ContainerView[T views.ViewCloner[T, V], V views.StructView[T]] struct {
	// contains filtered or unexported fields
}

ContainerView is a pre-defined read-only view of a Container[T].

func ContainerViewOf

func ContainerViewOf[T views.ViewCloner[T, V], V views.StructView[T]](c *Container[T]) ContainerView[T, V]

func (ContainerView[T, V]) Item

func (cv ContainerView[T, V]) Item() V

type GenericBasicStruct

type GenericBasicStruct[T BasicType] struct {
	Value T
}

type GenericCloneableStruct

type GenericCloneableStruct[T views.ViewCloner[T, V], V views.StructView[T]] struct {
	Value T
	Slice []T
	Map   map[string]T

	// Unsupported views.
	Pointer     *T
	PtrSlice    []*T
	PtrKeyMap   map[*T]string `json:"-"`
	PtrValueMap map[string]*T
	SliceMap    map[string][]T
}

func (*GenericCloneableStruct[T, V]) Clone

func (src *GenericCloneableStruct[T, V]) Clone() *GenericCloneableStruct[T, V]

Clone makes a deep copy of GenericCloneableStruct. The result aliases no memory with the original.

func (*GenericCloneableStruct[T, V]) View

func (p *GenericCloneableStruct[T, V]) View() GenericCloneableStructView[T, V]

View returns a read-only view of GenericCloneableStruct.

type GenericCloneableStructView

type GenericCloneableStructView[T views.ViewCloner[T, V], V views.StructView[T]] struct {
	// contains filtered or unexported fields
}

GenericCloneableStructView[T, V] provides a read-only view over GenericCloneableStruct[T, V].

Its methods should only be called if `Valid()` returns true.

func (GenericCloneableStructView[T, V]) AsStruct

func (v GenericCloneableStructView[T, V]) AsStruct() *GenericCloneableStruct[T, V]

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (GenericCloneableStructView[T, V]) Map

func (v GenericCloneableStructView[T, V]) Map() views.MapFn[string, T, V]

func (GenericCloneableStructView[T, V]) MarshalJSON

func (v GenericCloneableStructView[T, V]) MarshalJSON() ([]byte, error)

func (GenericCloneableStructView[T, V]) Pointer

func (v GenericCloneableStructView[T, V]) Pointer() map[string]T

func (GenericCloneableStructView[T, V]) PtrKeyMap

func (v GenericCloneableStructView[T, V]) PtrKeyMap() map[*T]string

func (GenericCloneableStructView[T, V]) PtrSlice

func (v GenericCloneableStructView[T, V]) PtrSlice() *T

func (GenericCloneableStructView[T, V]) PtrValueMap

func (v GenericCloneableStructView[T, V]) PtrValueMap() map[string]*T

func (GenericCloneableStructView[T, V]) Slice

func (v GenericCloneableStructView[T, V]) Slice() views.SliceView[T, V]

func (GenericCloneableStructView[T, V]) SliceMap

func (v GenericCloneableStructView[T, V]) SliceMap() map[string][]T

func (*GenericCloneableStructView[T, V]) UnmarshalJSON

func (v *GenericCloneableStructView[T, V]) UnmarshalJSON(b []byte) error

func (GenericCloneableStructView[T, V]) Valid

func (v GenericCloneableStructView[T, V]) Valid() bool

Valid reports whether v's underlying value is non-nil.

func (GenericCloneableStructView[T, V]) Value

func (v GenericCloneableStructView[T, V]) Value() V

type GenericIntStruct

type GenericIntStruct[T constraints.Integer] struct {
	Value   T
	Pointer *T
	Slice   []T
	Map     map[string]T

	// Unsupported views.
	PtrSlice    []*T
	PtrKeyMap   map[*T]string `json:"-"`
	PtrValueMap map[string]*T
	SliceMap    map[string][]T
}

func (*GenericIntStruct[T]) Clone

func (src *GenericIntStruct[T]) Clone() *GenericIntStruct[T]

Clone makes a deep copy of GenericIntStruct. The result aliases no memory with the original.

func (*GenericIntStruct[T]) View

func (p *GenericIntStruct[T]) View() GenericIntStructView[T]

View returns a read-only view of GenericIntStruct.

type GenericIntStructView

type GenericIntStructView[T constraints.Integer] struct {
	// contains filtered or unexported fields
}

GenericIntStructView[T] provides a read-only view over GenericIntStruct[T].

Its methods should only be called if `Valid()` returns true.

func (GenericIntStructView[T]) AsStruct

func (v GenericIntStructView[T]) AsStruct() *GenericIntStruct[T]

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (GenericIntStructView[T]) Map

func (v GenericIntStructView[T]) Map() views.Map[string, T]

func (GenericIntStructView[T]) MarshalJSON

func (v GenericIntStructView[T]) MarshalJSON() ([]byte, error)

func (GenericIntStructView[T]) Pointer

func (v GenericIntStructView[T]) Pointer() views.ValuePointer[T]

func (GenericIntStructView[T]) PtrKeyMap

func (v GenericIntStructView[T]) PtrKeyMap() map[*T]string

func (GenericIntStructView[T]) PtrSlice

func (v GenericIntStructView[T]) PtrSlice() *T

func (GenericIntStructView[T]) PtrValueMap

func (v GenericIntStructView[T]) PtrValueMap() map[string]*T

func (GenericIntStructView[T]) Slice

func (v GenericIntStructView[T]) Slice() views.Slice[T]

func (GenericIntStructView[T]) SliceMap

func (v GenericIntStructView[T]) SliceMap() map[string][]T

func (*GenericIntStructView[T]) UnmarshalJSON

func (v *GenericIntStructView[T]) UnmarshalJSON(b []byte) error

func (GenericIntStructView[T]) Valid

func (v GenericIntStructView[T]) Valid() bool

Valid reports whether v's underlying value is non-nil.

func (GenericIntStructView[T]) Value

func (v GenericIntStructView[T]) Value() T

type GenericNoPtrsStruct

type GenericNoPtrsStruct[T StructWithoutPtrs | netip.Prefix | BasicType] struct {
	Value   T
	Pointer *T
	Slice   []T
	Map     map[string]T

	// Unsupported views.
	PtrSlice    []*T
	PtrKeyMap   map[*T]string `json:"-"`
	PtrValueMap map[string]*T
	SliceMap    map[string][]T
}

func (*GenericNoPtrsStruct[T]) Clone

func (src *GenericNoPtrsStruct[T]) Clone() *GenericNoPtrsStruct[T]

Clone makes a deep copy of GenericNoPtrsStruct. The result aliases no memory with the original.

func (*GenericNoPtrsStruct[T]) View

View returns a read-only view of GenericNoPtrsStruct.

type GenericNoPtrsStructView

type GenericNoPtrsStructView[T StructWithoutPtrs | netip.Prefix | BasicType] struct {
	// contains filtered or unexported fields
}

GenericNoPtrsStructView[T] provides a read-only view over GenericNoPtrsStruct[T].

Its methods should only be called if `Valid()` returns true.

func (GenericNoPtrsStructView[T]) AsStruct

func (v GenericNoPtrsStructView[T]) AsStruct() *GenericNoPtrsStruct[T]

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (GenericNoPtrsStructView[T]) Map

func (v GenericNoPtrsStructView[T]) Map() views.Map[string, T]

func (GenericNoPtrsStructView[T]) MarshalJSON

func (v GenericNoPtrsStructView[T]) MarshalJSON() ([]byte, error)

func (GenericNoPtrsStructView[T]) Pointer

func (v GenericNoPtrsStructView[T]) Pointer() views.ValuePointer[T]

func (GenericNoPtrsStructView[T]) PtrKeyMap

func (v GenericNoPtrsStructView[T]) PtrKeyMap() map[*T]string

func (GenericNoPtrsStructView[T]) PtrSlice

func (v GenericNoPtrsStructView[T]) PtrSlice() *T

func (GenericNoPtrsStructView[T]) PtrValueMap

func (v GenericNoPtrsStructView[T]) PtrValueMap() map[string]*T

func (GenericNoPtrsStructView[T]) Slice

func (v GenericNoPtrsStructView[T]) Slice() views.Slice[T]

func (GenericNoPtrsStructView[T]) SliceMap

func (v GenericNoPtrsStructView[T]) SliceMap() map[string][]T

func (*GenericNoPtrsStructView[T]) UnmarshalJSON

func (v *GenericNoPtrsStructView[T]) UnmarshalJSON(b []byte) error

func (GenericNoPtrsStructView[T]) Valid

func (v GenericNoPtrsStructView[T]) Valid() bool

Valid reports whether v's underlying value is non-nil.

func (GenericNoPtrsStructView[T]) Value

func (v GenericNoPtrsStructView[T]) Value() T

type GenericTypeAliasStruct

type GenericTypeAliasStruct[T integer, T2 views.ViewCloner[T2, V2], V2 views.StructView[T2]] struct {
	NonCloneable T
	Cloneable    T2
}

func (*GenericTypeAliasStruct[T, T2, V2]) Clone

func (src *GenericTypeAliasStruct[T, T2, V2]) Clone() *GenericTypeAliasStruct[T, T2, V2]

Clone makes a deep copy of GenericTypeAliasStruct. The result aliases no memory with the original.

func (*GenericTypeAliasStruct[T, T2, V2]) View

func (p *GenericTypeAliasStruct[T, T2, V2]) View() GenericTypeAliasStructView[T, T2, V2]

View returns a read-only view of GenericTypeAliasStruct.

type GenericTypeAliasStructView

type GenericTypeAliasStructView[T integer, T2 views.ViewCloner[T2, V2], V2 views.StructView[T2]] struct {
	// contains filtered or unexported fields
}

GenericTypeAliasStructView[T, T2, V2] provides a read-only view over GenericTypeAliasStruct[T, T2, V2].

Its methods should only be called if `Valid()` returns true.

func (GenericTypeAliasStructView[T, T2, V2]) AsStruct

func (v GenericTypeAliasStructView[T, T2, V2]) AsStruct() *GenericTypeAliasStruct[T, T2, V2]

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (GenericTypeAliasStructView[T, T2, V2]) Cloneable

func (v GenericTypeAliasStructView[T, T2, V2]) Cloneable() V2

func (GenericTypeAliasStructView[T, T2, V2]) MarshalJSON

func (v GenericTypeAliasStructView[T, T2, V2]) MarshalJSON() ([]byte, error)

func (GenericTypeAliasStructView[T, T2, V2]) NonCloneable

func (v GenericTypeAliasStructView[T, T2, V2]) NonCloneable() T

func (*GenericTypeAliasStructView[T, T2, V2]) UnmarshalJSON

func (v *GenericTypeAliasStructView[T, T2, V2]) UnmarshalJSON(b []byte) error

func (GenericTypeAliasStructView[T, T2, V2]) Valid

func (v GenericTypeAliasStructView[T, T2, V2]) Valid() bool

Valid reports whether v's underlying value is non-nil.

type Map

type Map struct {
	Int                 map[string]int
	SliceInt            map[string][]int
	StructPtrWithPtr    map[string]*StructWithPtrs
	StructPtrWithoutPtr map[string]*StructWithoutPtrs
	StructWithoutPtr    map[string]StructWithoutPtrs
	SlicesWithPtrs      map[string][]*StructWithPtrs
	SlicesWithoutPtrs   map[string][]*StructWithoutPtrs
	StructWithoutPtrKey map[StructWithoutPtrs]int `json:"-"`
	StructWithPtr       map[string]StructWithPtrs

	// Unsupported views.
	SliceIntPtr      map[string][]*int
	PointerKey       map[*string]int        `json:"-"`
	StructWithPtrKey map[StructWithPtrs]int `json:"-"`
}

func (*Map) Clone

func (src *Map) Clone() *Map

Clone makes a deep copy of Map. The result aliases no memory with the original.

func (*Map) View

func (p *Map) View() MapView

View returns a read-only view of Map.

type MapContainer

type MapContainer[K comparable, V views.Cloner[V]] struct {
	Items map[K]V
}

MapContainer is a predefined map-like container type. Unlike Container, it has two type parameters, where the value is the second parameter.

func (*MapContainer[K, V]) Clone

func (c *MapContainer[K, V]) Clone() *MapContainer[K, V]

type MapContainerView

type MapContainerView[K comparable, T views.ViewCloner[T, V], V views.StructView[T]] struct {
	// contains filtered or unexported fields
}

MapContainerView is a pre-defined read-only view of a MapContainer[K, T].

func MapContainerViewOf

func MapContainerViewOf[K comparable, T views.ViewCloner[T, V], V views.StructView[T]](c *MapContainer[K, T]) MapContainerView[K, T, V]

func (MapContainerView[K, T, V]) Items

func (cv MapContainerView[K, T, V]) Items() views.MapFn[K, T, V]

type MapView

type MapView struct {
	// contains filtered or unexported fields
}

MapView provides a read-only view over Map.

Its methods should only be called if `Valid()` returns true.

func (MapView) AsStruct

func (v MapView) AsStruct() *Map

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (MapView) Int

func (v MapView) Int() views.Map[string, int]

func (MapView) MarshalJSON

func (v MapView) MarshalJSON() ([]byte, error)

func (MapView) PointerKey

func (v MapView) PointerKey() map[*string]int

func (MapView) SliceInt

func (v MapView) SliceInt() views.MapSlice[string, int]

func (MapView) SliceIntPtr

func (v MapView) SliceIntPtr() map[string][]*int

func (MapView) SlicesWithPtrs

func (MapView) SlicesWithoutPtrs

func (MapView) StructPtrWithPtr

func (v MapView) StructPtrWithPtr() views.MapFn[string, *StructWithPtrs, StructWithPtrsView]

func (MapView) StructPtrWithoutPtr

func (v MapView) StructPtrWithoutPtr() views.MapFn[string, *StructWithoutPtrs, StructWithoutPtrsView]

func (MapView) StructWithPtr

func (MapView) StructWithPtrKey

func (v MapView) StructWithPtrKey() map[StructWithPtrs]int

func (MapView) StructWithoutPtr

func (v MapView) StructWithoutPtr() views.Map[string, StructWithoutPtrs]

func (MapView) StructWithoutPtrKey

func (v MapView) StructWithoutPtrKey() views.Map[StructWithoutPtrs, int]

func (*MapView) UnmarshalJSON

func (v *MapView) UnmarshalJSON(b []byte) error

func (MapView) Valid

func (v MapView) Valid() bool

Valid reports whether v's underlying value is non-nil.

type OnlyGetClone

type OnlyGetClone struct {
	SinViewerPorFavor bool
}

func (*OnlyGetClone) Clone

func (src *OnlyGetClone) Clone() *OnlyGetClone

Clone makes a deep copy of OnlyGetClone. The result aliases no memory with the original.

type StructWithContainers

type StructWithContainers struct {
	IntContainer              Container[int]
	CloneableContainer        Container[*StructWithPtrs]
	BasicGenericContainer     Container[GenericBasicStruct[int]]
	CloneableGenericContainer Container[*GenericNoPtrsStruct[int]]
	CloneableMap              MapContainer[int, *StructWithPtrs]
	CloneableGenericMap       MapContainer[int, *GenericNoPtrsStruct[int]]
}

func (*StructWithContainers) Clone

Clone makes a deep copy of StructWithContainers. The result aliases no memory with the original.

func (*StructWithContainers) View

View returns a read-only view of StructWithContainers.

type StructWithContainersView

type StructWithContainersView struct {
	// contains filtered or unexported fields
}

StructWithContainersView provides a read-only view over StructWithContainers.

Its methods should only be called if `Valid()` returns true.

func (StructWithContainersView) AsStruct

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithContainersView) BasicGenericContainer

func (v StructWithContainersView) BasicGenericContainer() Container[GenericBasicStruct[int]]

func (StructWithContainersView) CloneableContainer

func (StructWithContainersView) CloneableGenericContainer

func (StructWithContainersView) CloneableGenericMap

func (StructWithContainersView) CloneableMap

func (StructWithContainersView) IntContainer

func (v StructWithContainersView) IntContainer() Container[int]

func (StructWithContainersView) MarshalJSON

func (v StructWithContainersView) MarshalJSON() ([]byte, error)

func (*StructWithContainersView) UnmarshalJSON

func (v *StructWithContainersView) UnmarshalJSON(b []byte) error

func (StructWithContainersView) Valid

func (v StructWithContainersView) Valid() bool

Valid reports whether v's underlying value is non-nil.

type StructWithEmbedded

type StructWithEmbedded struct {
	A *StructWithPtrs
	StructWithSlices
}

func (*StructWithEmbedded) Clone

func (src *StructWithEmbedded) Clone() *StructWithEmbedded

Clone makes a deep copy of StructWithEmbedded. The result aliases no memory with the original.

func (*StructWithEmbedded) View

View returns a read-only view of StructWithEmbedded.

type StructWithEmbeddedView

type StructWithEmbeddedView struct {
	// contains filtered or unexported fields
}

StructWithEmbeddedView provides a read-only view over StructWithEmbedded.

Its methods should only be called if `Valid()` returns true.

func (StructWithEmbeddedView) A

func (StructWithEmbeddedView) AsStruct

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithEmbeddedView) MarshalJSON

func (v StructWithEmbeddedView) MarshalJSON() ([]byte, error)

func (StructWithEmbeddedView) StructWithSlices

func (v StructWithEmbeddedView) StructWithSlices() StructWithSlicesView

func (*StructWithEmbeddedView) UnmarshalJSON

func (v *StructWithEmbeddedView) UnmarshalJSON(b []byte) error

func (StructWithEmbeddedView) Valid

func (v StructWithEmbeddedView) Valid() bool

Valid reports whether v's underlying value is non-nil.

type StructWithNoView

type StructWithNoView struct {
	Value int
}

type StructWithPtrs

type StructWithPtrs struct {
	Value  *StructWithoutPtrs
	Int    *int
	NoView *StructWithNoView

	NoCloneValue *StructWithoutPtrs `codegen:"noclone"`
}

func (*StructWithPtrs) Clone

func (src *StructWithPtrs) Clone() *StructWithPtrs

Clone makes a deep copy of StructWithPtrs. The result aliases no memory with the original.

func (*StructWithPtrs) Equal

func (v *StructWithPtrs) Equal(v2 *StructWithPtrs) bool

func (*StructWithPtrs) String

func (v *StructWithPtrs) String() string

func (*StructWithPtrs) View

View returns a read-only view of StructWithPtrs.

type StructWithPtrsAlias

type StructWithPtrsAlias = StructWithPtrs

type StructWithPtrsAliasView

type StructWithPtrsAliasView = StructWithPtrsView

type StructWithPtrsView

type StructWithPtrsView struct {
	// contains filtered or unexported fields
}

StructWithPtrsView provides a read-only view over StructWithPtrs.

Its methods should only be called if `Valid()` returns true.

func (StructWithPtrsView) AsStruct

func (v StructWithPtrsView) AsStruct() *StructWithPtrs

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithPtrsView) Equal

func (StructWithPtrsView) Int

func (StructWithPtrsView) MarshalJSON

func (v StructWithPtrsView) MarshalJSON() ([]byte, error)

func (StructWithPtrsView) NoCloneValue

func (v StructWithPtrsView) NoCloneValue() *StructWithoutPtrs

func (StructWithPtrsView) NoView

func (StructWithPtrsView) String

func (v StructWithPtrsView) String() string

func (*StructWithPtrsView) UnmarshalJSON

func (v *StructWithPtrsView) UnmarshalJSON(b []byte) error

func (StructWithPtrsView) Valid

func (v StructWithPtrsView) Valid() bool

Valid reports whether v's underlying value is non-nil.

func (StructWithPtrsView) Value

type StructWithSlices

type StructWithSlices struct {
	Values         []StructWithoutPtrs
	ValuePointers  []*StructWithoutPtrs
	StructPointers []*StructWithPtrs

	Slice    []string
	Prefixes []netip.Prefix
	Data     []byte

	// Unsupported views.
	Structs []StructWithPtrs
	Ints    []*int
}

func (*StructWithSlices) Clone

func (src *StructWithSlices) Clone() *StructWithSlices

Clone makes a deep copy of StructWithSlices. The result aliases no memory with the original.

func (*StructWithSlices) View

View returns a read-only view of StructWithSlices.

type StructWithSlicesView

type StructWithSlicesView struct {
	// contains filtered or unexported fields
}

StructWithSlicesView provides a read-only view over StructWithSlices.

Its methods should only be called if `Valid()` returns true.

func (StructWithSlicesView) AsStruct

func (v StructWithSlicesView) AsStruct() *StructWithSlices

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithSlicesView) Data

func (StructWithSlicesView) Ints

func (v StructWithSlicesView) Ints() *int

func (StructWithSlicesView) MarshalJSON

func (v StructWithSlicesView) MarshalJSON() ([]byte, error)

func (StructWithSlicesView) Prefixes

func (StructWithSlicesView) Slice

func (StructWithSlicesView) StructPointers

func (StructWithSlicesView) Structs

func (*StructWithSlicesView) UnmarshalJSON

func (v *StructWithSlicesView) UnmarshalJSON(b []byte) error

func (StructWithSlicesView) Valid

func (v StructWithSlicesView) Valid() bool

Valid reports whether v's underlying value is non-nil.

func (StructWithSlicesView) ValuePointers

func (StructWithSlicesView) Values

type StructWithTypeAliasFields

type StructWithTypeAliasFields struct {
	WithPtr    StructWithPtrsAlias
	WithoutPtr StructWithoutPtrsAlias

	WithPtrByPtr    *StructWithPtrsAlias
	WithoutPtrByPtr *StructWithoutPtrsAlias

	SliceWithPtrs    []*StructWithPtrsAlias
	SliceWithoutPtrs []*StructWithoutPtrsAlias

	MapWithPtrs    map[string]*StructWithPtrsAlias
	MapWithoutPtrs map[string]*StructWithoutPtrsAlias

	MapOfSlicesWithPtrs    map[string][]*StructWithPtrsAlias
	MapOfSlicesWithoutPtrs map[string][]*StructWithoutPtrsAlias
}

func (*StructWithTypeAliasFields) Clone

Clone makes a deep copy of StructWithTypeAliasFields. The result aliases no memory with the original.

func (*StructWithTypeAliasFields) View

View returns a read-only view of StructWithTypeAliasFields.

type StructWithTypeAliasFieldsView

type StructWithTypeAliasFieldsView struct {
	// contains filtered or unexported fields
}

StructWithTypeAliasFieldsView provides a read-only view over StructWithTypeAliasFields.

Its methods should only be called if `Valid()` returns true.

func (StructWithTypeAliasFieldsView) AsStruct

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithTypeAliasFieldsView) MapOfSlicesWithPtrs

func (StructWithTypeAliasFieldsView) MapOfSlicesWithoutPtrs

func (StructWithTypeAliasFieldsView) MapWithPtrs

func (StructWithTypeAliasFieldsView) MapWithoutPtrs

func (StructWithTypeAliasFieldsView) MarshalJSON

func (v StructWithTypeAliasFieldsView) MarshalJSON() ([]byte, error)

func (StructWithTypeAliasFieldsView) SliceWithPtrs

func (StructWithTypeAliasFieldsView) SliceWithoutPtrs

func (*StructWithTypeAliasFieldsView) UnmarshalJSON

func (v *StructWithTypeAliasFieldsView) UnmarshalJSON(b []byte) error

func (StructWithTypeAliasFieldsView) Valid

Valid reports whether v's underlying value is non-nil.

func (StructWithTypeAliasFieldsView) WithPtr

func (StructWithTypeAliasFieldsView) WithPtrByPtr

func (StructWithTypeAliasFieldsView) WithoutPtr

func (StructWithTypeAliasFieldsView) WithoutPtrByPtr

type StructWithoutPtrs

type StructWithoutPtrs struct {
	Int int
	Pfx netip.Prefix
}

func (*StructWithoutPtrs) Clone

func (src *StructWithoutPtrs) Clone() *StructWithoutPtrs

Clone makes a deep copy of StructWithoutPtrs. The result aliases no memory with the original.

func (*StructWithoutPtrs) View

View returns a read-only view of StructWithoutPtrs.

type StructWithoutPtrsAlias

type StructWithoutPtrsAlias = StructWithoutPtrs

type StructWithoutPtrsAliasView

type StructWithoutPtrsAliasView = StructWithoutPtrsView

type StructWithoutPtrsView

type StructWithoutPtrsView struct {
	// contains filtered or unexported fields
}

StructWithoutPtrsView provides a read-only view over StructWithoutPtrs.

Its methods should only be called if `Valid()` returns true.

func (StructWithoutPtrsView) AsStruct

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithoutPtrsView) Int

func (v StructWithoutPtrsView) Int() int

func (StructWithoutPtrsView) MarshalJSON

func (v StructWithoutPtrsView) MarshalJSON() ([]byte, error)

func (StructWithoutPtrsView) Pfx

func (*StructWithoutPtrsView) UnmarshalJSON

func (v *StructWithoutPtrsView) UnmarshalJSON(b []byte) error

func (StructWithoutPtrsView) Valid

func (v StructWithoutPtrsView) Valid() bool

Valid reports whether v's underlying value is non-nil.

Source Files

tests.go tests_clone.go tests_view.go

Version
v1.82.5 (latest)
Published
Apr 17, 2025
Platform
linux/amd64
Imports
8 packages
Last checked
9 hours ago

Tools for package owners.