trans

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package trans implements the functions, types, and interfaces for the module.

Package trans implements the functions, types, and interfaces for the module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cast

func Cast[T any](v any) (ret T, ok bool)

Cast attempts to convert a value to the specified type. If the conversion is successful, it returns the converted value and true. If the conversion fails, it returns the original value and false.

func CastOr

func CastOr[T any](v any, def T) T

CastOr attempts to convert a value to the specified type. If the conversion is successful, it returns the converted value. If the conversion fails, it returns the default value.

func CastOrZero

func CastOrZero[T comparable](v any) T

CastOrZero attempts to convert a value to the specified type. If the conversion is successful, it returns the converted value. If the conversion fails, it returns a zero value of the specified type.

func MustCast

func MustCast[T any](v any) T

MustCast attempts to convert a value to the specified type. If the conversion is successful, it returns the converted value. If the conversion fails, it panics with the message.

func Pointer

func Pointer[T any](v T) *T

Pointer returns a pointer to value of Type.

func Value

func Value[T any](v *T) T

Value returns the value of the pointer of Type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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