generictype

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Boolean = &GenericType{
	slug: "boolean",
	cat:  typecategory.Basic,
	kinds: []string{
		reflect.Bool.String(),
	},
}

Basic types.

View Source
var DateTime = &GenericType{
	slug: "datetime",
	cat:  typecategory.Known,
	kinds: []string{
		"time.Time",
	},
}
View Source
var Float = &GenericType{
	slug: "float",
	cat:  typecategory.Basic,
	kinds: []string{
		reflect.Float32.String(),
		reflect.Float64.String(),
	},
}
View Source
var Integer = &GenericType{
	slug: "integer",
	cat:  typecategory.Basic,
	kinds: []string{
		reflect.Int.String(),
		reflect.Int8.String(),
		reflect.Int16.String(),
		reflect.Int32.String(),
		reflect.Int64.String(),
		reflect.Uint.String(),
		reflect.Uint8.String(),
		reflect.Uint16.String(),
		reflect.Uint32.String(),
		reflect.Uint64.String(),
		reflect.Uintptr.String(),
	},
}
View Source
var Interface = &GenericType{
	slug:        "interface",
	pathDefault: "{?}",
	cat:         typecategory.Reference,
	kinds: []string{
		reflect.Interface.String(),
	},
}

Reference types.

View Source
var Invalid = &GenericType{
	slug: "invalid",
	cat:  typecategory.Invalid,
	kinds: []string{
		reflect.Invalid.String(),
		reflect.Complex64.String(),
		reflect.Complex128.String(),
		reflect.Chan.String(),
		reflect.Func.String(),
		reflect.UnsafePointer.String(),
	},
}

Invalid types are not allowed in shiny schemas.

View Source
var List = &GenericType{
	slug:        "list",
	pathDefault: "[]",
	cat:         typecategory.Compound,
	kinds: []string{
		reflect.Array.String(),
		reflect.Slice.String(),
	},
}

Compound types.

View Source
var Pointer = &GenericType{
	slug:        "pointer",
	pathDefault: "*",
	cat:         typecategory.Reference,
	kinds: []string{
		reflect.Ptr.String(),
	},
}
View Source
var Root = &GenericType{
	slug:        "root",
	pathDefault: "$",
	cat:         typecategory.Internal,
	kinds:       []string{},
}

Root is at the top of any type tree.

View Source
var String = &GenericType{
	slug: "string",
	cat:  typecategory.Basic,
	kinds: []string{
		reflect.String.String(),
	},
}
View Source
var Struct = &GenericType{
	slug:        "struct",
	pathDefault: "{}",
	cat:         typecategory.Compound,
	kinds: []string{
		reflect.Map.String(),
		reflect.Struct.String(),
	},
}

Functions

func PathDefaultOfType

func PathDefaultOfType(typeString string) string

PathDefaultOfType returns the path default for a given generic type string.

Types

type GenericType

type GenericType struct {
	// contains filtered or unexported fields
}

GenericType defines generic types for shiny schemas. Uses slugs from: https://threedots.tech/post/safer-enums-in-go/

func GenericTypeOf

func GenericTypeOf(v reflect.Value) *GenericType

GenericTypeOf returns the GenericType of the given reflect.Value.

func (*GenericType) Category

func (t *GenericType) Category() typecategory.TypeCategory

Category returns the TypeCategory for the GenericType.

func (*GenericType) PathDefault

func (t *GenericType) PathDefault() string

PathDefault returns the default path string for the GenericType.

func (*GenericType) String

func (t *GenericType) String() string

String returns GenericType as a string.

Jump to

Keyboard shortcuts

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