conv

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package conv provides a simple way to convert between types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conv

func Conv[T Numbers](def T, v any) T

Conv this can lose data i.e converting int32 to int8

func Deref

func Deref(v any) any

func ToAnySlice

func ToAnySlice[T any](vs []T) []any

ToAnySlice converts a []T to []any, useful to pass params.

func ToNumberSlice

func ToNumberSlice[T Numbers](vs []any) []T

Convert []any to a typed T if an element has an invalid converstion a zero T will be used

func ToString

func ToString(v any) string

Types

type Numbers

type Numbers interface {
	constraints.Integer | constraints.Float
}

Jump to

Keyboard shortcuts

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