Help us shape the future of Go! Take the 2026 Go Developer Survey

typeconverters

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertGivenTypeToString

func ConvertGivenTypeToString(value interface{}, goType string) (output string, exists bool, err error)

ConvertGivenTypeToString converts a given Go type to a string.

Parameters: - value: an interface containing the value to convert - goType: a string containing the Go type to convert from

Returns: - output: a string containing the converted value - exists: a bool indicating whether the conversion was successful - err: an error containing the error message

func ConvertStringToGivenType

func ConvertStringToGivenType(value string, goType string) (output interface{}, exists bool, err error)

ConvertStringToGivenType converts a string to a given Go type.

Parameters: - value: a string containing the value to convert - goType: a string containing the Go type to convert to

Returns: - output: an interface containing the converted value - exists: a bool indicating whether the conversion was successful - err: an error containing the error message

func DeepCopy

func DeepCopy(src, dst interface{}) (err error)

DeepCopy deep copies the source interface to the destination interface.

Parameters: - src: an interface containing the source - dst: an interface containing the destination

Returns: - err: an error containing the error message

func GetSupportedTypes added in v1.0.5

func GetSupportedTypes() []string

GetSupportedTypes returns a list of all Go types supported by ConvertStringToGivenType.

Returns: - []string: a slice containing all supported Go type names

func GoToJSON

func GoToJSON(goType string) string

GoToJSON converts a Go data type to a JSON data type.

Parameters:

goType: The Go data type to convert.

Returns:

string: The JSON data type.

func JSONToGo

func JSONToGo(jsonType string) (string, error)

JSONToGo converts a JSON data type to a Go data type.

Parameters:

jsonType: The JSON data type to convert.

Returns:

string: The Go data type.
error: An error if the JSON data type is not supported.

Types

type TypeConverter added in v1.0.5

type TypeConverter struct {
	FromString func(value string) (interface{}, error)
	ToString   func(value interface{}) (string, error)
}

TypeConverter holds functions to convert to and from a given Go type

Jump to

Keyboard shortcuts

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