data

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

README

Data 👋

Description

Data is a Go package that provides data manipulations.

Requirements

Go 1.15 or above.

Getting Started

Installation

Run the following command to install the package:

go get github.com/leliuga/data

License

This project is licensed under the Mozilla Public License Version 2.0 License - see the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	DefaultDateFormat     = "2006-01-02"
	DefaultDateTimeFormat = "2006-01-02 15:04:05"
	DefaultTimeFormat     = "15:04:05"
)

Default values for the date/time formats

Variables

View Source
var (
	KindNames = map[Kind]string{
		KindReference: "Reference",
		KindBoolean:   "Boolean",
		KindDateTime:  "Datetime",
		KindDate:      "Date",
		KindFloat32:   "Float32",
		KindFloat64:   "Float64",
		KindID:        "Id",
		KindInet:      "Inet",
		KindUInt8:     "Uint8",
		KindUInt16:    "Uint16",
		KindUInt32:    "Uint32",
		KindUInt64:    "Uint64",
		KindInt8:      "Int8",
		KindInt16:     "Int16",
		KindInt32:     "Int32",
		KindInt64:     "Int64",
		KindString:    "String",
		KindTime:      "Time",
	}

	// ErrKindInvalid is returned when the data kind is invalid.
	ErrKindInvalid = errors.New("invalid data kind")
)

Functions

This section is empty.

Types

type IModel added in v1.1.0

type IModel interface {
	// Validate makes `Model` validatable by implementing [validation.Validatable] interface.
	Validate() error
}

IModel defines a model interface.

type Kind

type Kind uint8

Kind defines a data kind.

const (
	KindInvalid   Kind = iota + 1 //
	KindReference                 // The `reference`scalar kind represents a reference to other structure Columns
	KindBoolean                   // The `boolean`  scalar kind represents                                                                        value `true` or `false`
	KindDateTime                  // The `datetime` scalar kind represents a date and time pairing in UTC                                         value `2023-01-25 10:10:10`
	KindDate                      // The `date`     scalar kind represents a date in UTC                                                          value `2023-01-25`
	KindFloat32                   // The `float32`  scalar kind represents an 32-bit signed double-precision floating-point                       value '1.2345'
	KindFloat64                   // The `float64`  scalar kind represents an 64-bit signed double-precision floating-point                       value '1.2345'
	KindID                        // The `id`       scalar kind represents a 128-bit hexadecimal                                                  value '7f9c24e8-3b12-4fef-91e0-56a2d5a246ec'
	KindInet                      // The `inet`     scalar kind represents an IPv4 or IPv6 address                                                value '192.168.0.1'
	KindUInt8                     // The `uint8`    scalar kind represents an unsigned  8-bit integers (0 to 255)                                 value '12345'
	KindUInt16                    // The `uint16`   scalar kind represents an unsigned 16-bit integers (0 to 65535)                               value '12345'
	KindUInt32                    // The `uint32`   scalar kind represents an unsigned 32-bit integers (0 to 4294967295)                          value '12345'
	KindUInt64                    // The `uint64`   scalar kind represents an unsigned 64-bit integers (0 to 18446744073709551615)                value '12345'
	KindInt8                      // The `int8`     scalar kind represents a signed  8-bit integers (-128 to 127)                                 value '-12'
	KindInt16                     // The `int16`    scalar kind represents a signed 16-bit integers (-32768 to 32767)                             value '-12'
	KindInt32                     // The `int32`    scalar kind represents a signed 32-bit integers (-2147483648 to 2147483647)                   value '-12'
	KindInt64                     // The `int64`    scalar kind represents a signed 64-bit integers (-9223372036854775808 to 9223372036854775807) value '-12'
	KindString                    // The `string`   scalar kind represents textual data a UTF‐8 character sequence                                value 'a1b2c3'
	KindTime                      // The `time`     scalar kind represents a time in UTC                                                          value `01:23:45.123456`
)

func DetectValueKind

func DetectValueKind(value any, convert bool) Kind

func MustParseKind

func MustParseKind(name string) Kind

MustParseKind parses data kind string or panics.

func ParseKind

func ParseKind(name string) Kind

ParseKind parses data kind string.

func (Kind) MarshalJSON

func (k Kind) MarshalJSON() ([]byte, error)

MarshalJSON data kind to json

func (Kind) String

func (k Kind) String() string

String data kind to string

func (*Kind) UnmarshalJSON

func (k *Kind) UnmarshalJSON(b []byte) error

UnmarshalJSON data kind from json

Jump to

Keyboard shortcuts

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