convert

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilPtr = errors.New("destination pointer is nil") // embedded in descriptive error

ErrNilPtr represents an error

Functions

func AsBigFloat

func AsBigFloat(src any) (*big.Float, error)

AsBigFloat converts interface as big.Float

func AsBool

func AsBool(src any) (bool, error)

AsBool convert interface as bool

func AsBytes

func AsBytes(src any) ([]byte, bool)

AsBytes converts interface as bytes

func AsFloat64

func AsFloat64(src any) (float64, error)

AsFloat64 convets interface as float64

func AsInt64

func AsInt64(src any) (int64, error)

AsInt64 converts interface as int64

func AsString

func AsString(src any) string

AsString converts interface as string

func AsTime

func AsTime(src any, dbLoc, uiLoc *time.Location) (*time.Time, error)

AsTime converts interface as time

func AsUint64

func AsUint64(src any) (uint64, error)

AsUint64 converts interface as uint64

func Assign

func Assign(dest, src any, originalLocation, convertedLocation *time.Location) error

Assign copies to dest the value in src, converting it if possible. An error is returned if the copy would result in loss of information. dest should be a pointer type.

func AssignValue

func AssignValue(dv reflect.Value, src any) error

AssignValue assign src as dv

func Interface2Interface

func Interface2Interface(userLocation *time.Location, v any) (any, error)

Interface2Interface converts interface of pointer as interface of value

func String2Time

func String2Time(s string, originalLocation, convertedLocation *time.Location) (*time.Time, error)

String2Time converts a string to time with original location be aware for time strings (HH:mm:ss) returns zero year (LMT) for converted location

Types

type Conversion

type Conversion interface {
	ConversionFrom
	ConversionTo
}

Conversion is an interface. A type implements Conversion will according the custom method to fill into database and retrieve from database.

type ConversionFrom

type ConversionFrom interface {
	FromDB([]byte) error
}

ConversionFrom is an inteface to allow retrieve data from database

type ConversionTo

type ConversionTo interface {
	ToDB() ([]byte, error)
}

ConversionTo is an interface to allow store data to database

type EmptyScanner

type EmptyScanner struct{}

EmptyScanner represents an empty scanner which will ignore the scan

func (EmptyScanner) Scan

func (EmptyScanner) Scan(value any) error

Scan implements sql.Scanner

type NullUint32

type NullUint32 struct {
	Uint32 uint32
	Valid  bool // Valid is true if Uint32 is not NULL
}

NullUint32 represents an uint32 that may be null. NullUint32 implements the Scanner interface so it can be used as a scan destination, similar to NullString.

func (*NullUint32) Scan

func (n *NullUint32) Scan(value any) error

Scan implements the Scanner interface.

func (NullUint32) Value

func (n NullUint32) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUint64

type NullUint64 struct {
	Uint64 uint64
	Valid  bool
}

NullUint64 represents an uint64 that may be null. NullUint64 implements the Scanner interface so it can be used as a scan destination, similar to NullString.

func (*NullUint64) Scan

func (n *NullUint64) Scan(value any) error

Scan implements the Scanner interface.

func (NullUint64) Value

func (n NullUint64) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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