typematcher

package
v0.0.0-...-5b643b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package typematcher defines matcher for types (e.g. NoLOck)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCloneByAssign

func IsCloneByAssign(ty types.Type, stepNext func(*types.Named) bool) bool

func IsNoCopy

func IsNoCopy(ty types.Type) bool

IsNoCopy returns true given type ty has Lock() method, or the ty contains direct (not indirected by pointer, map, slice, channel) dependency to no-lock object.

func Name

func Name(ty types.Type) (pkgPath string, name string)

Types

type ClonerMethod

type ClonerMethod struct {
	// Method name
	Name string
}

func (ClonerMethod) IsFuncImplementor

func (method ClonerMethod) IsFuncImplementor(ty types.Type) bool

func (ClonerMethod) IsImplementor

func (method ClonerMethod) IsImplementor(ty types.Type) bool

type CyclicConversionMethods

type CyclicConversionMethods struct {
	From    bool
	Reverse string
	Convert string
}

CyclicConversionMethods describes method that convert a type A to another type B through Convert, which can be converted back to A through Reverse. If From is false, an input type is assumed to be A, otherwise B.

func (CyclicConversionMethods) ConvertedType

func (mset CyclicConversionMethods) ConvertedType(ty *types.Named) (*types.Named, bool)

ConvertedType returns the type converted through Convert or Reverse depending on From. The returned value is true only if ty is implementor of mset, in that case returned *types.Named is guaranteed to be non-nil.

func (CyclicConversionMethods) IsImplementor

func (mset CyclicConversionMethods) IsImplementor(ty *types.Named) bool

IsImplementor check if given type ty is implementor of mset. Methods can be implemented on pointer receiver.

type ErrorMethod

type ErrorMethod struct {
	// Method name.
	Name string
}

ErrorMethod describes a method that takes no argument and returns a single error value. Method name must be as Name.

func (ErrorMethod) IsImplementor

func (method ErrorMethod) IsImplementor(ty *types.Named) bool

IsImplementor checks if ty implements a method named as [ErrorMethod.Name] that take no argument and returns an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL