types

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNil

func IsNil(i any) bool

IsNil checks that the interface contains a nil value.

Example
type Obj struct{}

var obj *Obj
var a any = obj
fmt.Println(IsNil(a))

obj = &Obj{}
a = obj
fmt.Println(IsNil(a))
Output:

true
false

func IsType

func IsType[T any](v any) bool

IsType checks type.

Example
type Obj1 struct{}
type Obj2 struct{}

fmt.Println(IsType[Obj1](Obj1{}))
fmt.Println(IsType[Obj2](Obj1{}))
Output:

true
false

func SameType

func SameType(v1, v2 any) bool

SameType checks that values has the same type. It uses the reflection.

Example
type Obj1 struct{}
type Obj2 struct{}

fmt.Println(SameType(Obj1{}, Obj1{}))
fmt.Println(SameType(Obj1{}, Obj2{}))
Output:

true
false

Types

This section is empty.

Jump to

Keyboard shortcuts

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