types

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package types holds utilities for working with different formats data types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataType

type DataType string

DataType represents data type.

const (
	Array    DataType = "array"
	Bool     DataType = "bool"
	Boolean  DataType = "boolean"
	DateTime DataType = "dateTime"
	Float    DataType = "float"
	Int      DataType = "int"
	Integer  DataType = "integer"
	Map      DataType = "map"
	Mapping  DataType = "mapping"
	Nil      DataType = "nil"
	Null     DataType = "null"
	Number   DataType = "number"
	Object   DataType = "object"
	Scalar   DataType = "scalar"
	Sequence DataType = "sequence"
	Slice    DataType = "slice"
	String   DataType = "string"
)
const (
	// Unknown represents unknown data type.
	Unknown DataType = "unknown"

	// Any represents any data type
	Any DataType = "any"
)

func (DataType) IsValidGoDataType

func (dt DataType) IsValidGoDataType() bool

IsValidGoDataType checks whether is valid Go-like data type.

func (DataType) IsValidJSONDataType

func (dt DataType) IsValidJSONDataType() bool

IsValidJSONDataType checks whether is valid JSON data type.

func (DataType) IsValidXMLDataType

func (dt DataType) IsValidXMLDataType() bool

IsValidXMLDataType checks whether is valid XML data type.

func (DataType) IsValidYAMLDataType

func (dt DataType) IsValidYAMLDataType() bool

IsValidYAMLDataType checks whether is valid YAML data type.

type GoTypeMapper

type GoTypeMapper struct{}

GoTypeMapper is entity that has ability to map underlying data type into corresponding Go-like data type.

func NewGoTypeMapper

func NewGoTypeMapper() GoTypeMapper

func (GoTypeMapper) Map

func (g GoTypeMapper) Map(data any) DataType

Map maps data underlying type into Go-like data type.

type JSONTypeMapper

type JSONTypeMapper struct{}

JSONTypeMapper is entity that has ability to map underlying data type into corresponding JSON data type.

func NewJSONTypeMapper

func NewJSONTypeMapper() JSONTypeMapper

func (JSONTypeMapper) Map

func (J JSONTypeMapper) Map(data any) DataType

Map maps underlying data type into corresponding JSON data type.

type Mapper

type Mapper interface {
	// Map maps data type.
	Map(data any) DataType
}

Mapper is entity that has ability to map data's type into corresponding DataType of given format.

type YAMLTypeMapper

type YAMLTypeMapper struct{}

YAMLTypeMapper is entity that has ability to map underlying data type into corresponding YAML data type.

func NewYAMLTypeMapper

func NewYAMLTypeMapper() YAMLTypeMapper

func (YAMLTypeMapper) Map

func (Y YAMLTypeMapper) Map(data any) DataType

Map maps underlying data type into corresponding YAML data type.

Jump to

Keyboard shortcuts

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