typesutil

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadType = errors.New("bad type")

Functions

func GetDirectiveName

func GetDirectiveName(v *types.Var) string

GetDirectiveName returns the name of the gosql directive type of the given variable. If the type of the given variable is not a directive an empty string will be returned instead.

func ImplementsAfterScanner

func ImplementsAfterScanner(named *types.Named) bool

ImplementsAfterScanner reports whether or not the given named type implements the "gosql.AfterScanner" interface.

func ImplementsErrorHandler

func ImplementsErrorHandler(named *types.Named) bool

ImplementsErrorHandler reports whether or not the given named type implements the "gosql.ErrorHandler" interface.

func ImplementsErrorInfoHandler

func ImplementsErrorInfoHandler(named *types.Named) bool

ImplementsErrorInfoHandler reports whether or not the given named type implements the "gosql.ErrorInfoHandler" interface.

func ImplementsGosqlConn

func ImplementsGosqlConn(named *types.Named) bool

ImplementsGosqlConn reports whether or not the given named type implements the "gosql.Conn" interface.

func ImplementsGosqlFilterConstructor

func ImplementsGosqlFilterConstructor(typ types.Type) bool

ImplementsGosqlFilterConstructor reports whether or not the given named type implements the "gosql.FilterConstructor" interface.

func ImplementsJSONMarshaler

func ImplementsJSONMarshaler(named *types.Named) bool

ImplementsJSONMarshaler reports whether or not the given named type implements the "encoding/json.Marshaler" interface. If the named type's underlying type is an interface type, ImplementsJSONMarshaler will report whether or not that interface type declares, or embeds, the "MarshalJSON() ([]byte, error)" method.

func ImplementsJSONUnmarshaler

func ImplementsJSONUnmarshaler(named *types.Named) bool

ImplementsJSONUnmarshaler reports whether or not the given named type implements the "encoding/json.Unmarshaler" interface. If the named type's underlying type is an interface type, ImplementsJSONUnmarshaler will report whether or not that interface type declares, or embeds, the "UnmarshalJSON([]byte) (error)" method.

func ImplementsScanner

func ImplementsScanner(named *types.Named) bool

ImplementsScanner reports whether or not the given named type implements the "database/sql.Scanner" interface. If the named type's underlying type is an interface type, ImplementsScanner will report whether or not that interface type declares, or embeds, the "Scan(interface{}) error" method.

func ImplementsValuer

func ImplementsValuer(named *types.Named) bool

ImplementsValuer reports whether or not the given named type implements the "database/sql/driver.Valuer" interface. If the named type's underlying type is an interface type, ImplementsValuer will report whether or not that interface type declares, or embeds, the "Value() (driver.Value, error)" method.

func ImplementsXMLMarshaler

func ImplementsXMLMarshaler(named *types.Named) bool

ImplementsXMLMarshaler reports whether or not the given named type implements the "encoding/xml.Marshaler" interface. If the named type's underlying type is an interface type, ImplementsXMLMarshaler will report whether or not that interface type declares, or embeds, the "MarshalXML(*xml.Encoder, xml.StartElement) (error)" method.

func ImplementsXMLUnmarshaler

func ImplementsXMLUnmarshaler(named *types.Named) bool

ImplementsXMLUnmarshaler reports whether or not the given named type implements the "encoding/xml.Unmarshaler" interface. If the named type's underlying type is an interface type, ImplementsXMLUnmarshaler will report whether or not that interface type declares, or embeds, the "UnmarshalXML(*xml.Decoder, xml.StartElement) (error)" method.

func IsContext

func IsContext(typ types.Type) bool

IsContext reports whether or not the given type is the standard "context.Context" type.

func IsDirective

func IsDirective(ident string, typ types.Type) bool

IsDirective reports whether or not the given type is a "github.com/frk/gosql" directive type.

func IsEmptyInterface

func IsEmptyInterface(typ types.Type) bool

IsEmptyInterface reports whether or not the given type is the "interface{}" type.

func IsEmptyInterfaceSlice added in v0.0.3

func IsEmptyInterfaceSlice(typ types.Type) bool

IsEmptyInterfaceSlice reports whether or not the given type is the "[]interface{}" type.

func IsError

func IsError(typ types.Type) bool

IsError reports whether or not the given type is the "error" type.

func IsJSONMarshaler

func IsJSONMarshaler(mm Methoder) bool

IsJSONMarshaler reports whether or not the given Methoder type declares, or embeds, the "MarshalJSON() ([]byte, error)" method.

func IsJSONUnmarshaler

func IsJSONUnmarshaler(mm Methoder) bool

IsJSONUnmarshaler reports whether or not the given Methoder type declares, or embeds, the "UnmarshalJSON([]byte) (error)" method.

func IsNiladicFunc

func IsNiladicFunc(typ types.Type) bool

IsNiladicFunc reports whether or not the given type is the "func()" type.

func IsScanner

func IsScanner(mm Methoder) bool

IsScanner reports whether or not the given Methoder type declares, or embeds, the "Scan(interface{}) error" method.

func IsSqlDriverValue

func IsSqlDriverValue(typ types.Type) bool

IsSqlDriverValue reports whether or not the given type is the "database/sql/driver.Value" type.

func IsSqlResult

func IsSqlResult(typ types.Type) bool

IsSqlResult reports whether or not the given type is the standard "sql.Result" type.

func IsSqlRowPtr

func IsSqlRowPtr(typ types.Type) bool

IsSqlRowPtr reports whether or not the given type is the standard "*sql.Row" type.

func IsSqlRowsPtr

func IsSqlRowsPtr(typ types.Type) bool

IsSqlRowsPtr reports whether or not the given type is the standard "*sql.Rows" type.

func IsString

func IsString(typ types.Type) bool

IsString reports whether or not the given type is the builtin "string" type.

func IsStringMap

func IsStringMap(typ types.Type) bool

IsStringMap reports whether or not the given type is the "map[string]string" type.

func IsTime

func IsTime(typ types.Type) bool

IsTime reports whether or not the given type is the "time.Time" type. IsTime returns true also for types that embed "time.Time" directly, this is to provide support for custom timestamp types.

func IsValuer

func IsValuer(mm Methoder) bool

IsValuer reports whether or not the given Methoder type declares, or embeds, the "Value() (driver.Value, error)" method.

func IsXMLMarshaler

func IsXMLMarshaler(mm Methoder) bool

IsXMLMarshaler reports whether or not the given Methoder type declares, or embeds, the "MarshalXML(*xml.Encoder, xml.StartElement) (error)" method.

func IsXMLUnmarshaler

func IsXMLUnmarshaler(mm Methoder) bool

IsXMLUnmarshaler reports whether or not the given Methoder type declares, or embeds, the "UnmarshalXML(*xml.Decoder, xml.StartElement) (error)" method.

Types

type Methoder

type Methoder interface {
	NumMethods() int
	Method(i int) *types.Func
}

Methoder represents a type with methods. It is implicitly implemented by *types.Interface and *types.Named.

type NamedStruct

type NamedStruct struct {
	Named  *types.Named
	Struct *types.Struct
}

func GetStruct

func GetStruct(v *types.Var) (*NamedStruct, error)

GetStruct is a helper function that returns a *NamedStruct value that represents the struct type of the the given *types.Var. If the struct type is unnamed then the Named field of the *NamedStruct value will remain uninitialized. If the var's type is not a struct then GetStruct will return an error.

Jump to

Keyboard shortcuts

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