types

package
v0.0.0-...-30262a5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2017 License: MIT Imports: 9 Imported by: 3

Documentation

Overview

Package types contains generic data types for use with SQL

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(message string, arguments ...interface{}) *string

Errorf creates a string pointer to an error message

Types

type BigUint64

type BigUint64 uint64

BigUint64 is an encapsulated uint64 that can be stored in a database

func (*BigUint64) Scan

func (b *BigUint64) Scan(src interface{}) error

Scan deserialises the object from raw database data

func (BigUint64) Value

func (b BigUint64) Value() (driver.Value, error)

Value serialises the object to raw database data

type Duration

type Duration time.Duration

Duration is an instance of time.Duration which implements the SQL Valuer and Scanner interfaces, so it can be stored in a database. Its SQL type should be integer.

func (*Duration) Scan

func (d *Duration) Scan(src interface{}) error

Scan deserialises the object from raw database data

func (Duration) Value

func (d Duration) Value() (driver.Value, error)

Value serialises the object to raw database data

type Language

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

Language represents an ISO639 language. Its SQL type could be varchar(3).

func MustParseLanguage

func MustParseLanguage(code string) Language

MustParseLanguage parses a language code (either 2-letter or 3-letter). Panics on failiure.

func NewLanguage

func NewLanguage(base language.Base) Language

NewLanguage creates a language from language.Base

func ParseLanguage

func ParseLanguage(code string) (Language, error)

ParseLanguage parses a language code (either 2-letter or 3-letter)

func (*Language) ISO2

func (l *Language) ISO2() string

ISO2 returns the 2-letter representation of the language

func (*Language) ISO3

func (l *Language) ISO3() string

ISO3 returns the 3-letter representation of the language

func (*Language) Scan

func (l *Language) Scan(src interface{}) error

Scan deserialises the object from raw database data

func (*Language) String

func (l *Language) String() string

String returns the 2-letter representation of the language (same as ISO2, implements the fmt.Stringer interface)

func (*Language) UnmarshalText

func (l *Language) UnmarshalText(text []byte) error

UnmarshalText parses a language code from raw text

func (Language) Value

func (l Language) Value() (driver.Value, error)

Value serialises the object to raw database data

type Languages

type Languages []Language

Languages represents an array of languages (its SQL type should be text or varchar)

func MustParseLanguages

func MustParseLanguages(spaceSeparatedCodes string) Languages

MustParseLanguages parses languages from a space-separated list of language codes, and panics on failiure

func NewLanguages

func NewLanguages(bases []language.Base) Languages

NewLanguages creates a list of languages based on bases

func ParseLanguages

func ParseLanguages(spaceSeparatedCodes string) (Languages, error)

ParseLanguages parses languages from a space-separated list of language codes

func (*Languages) Scan

func (l *Languages) Scan(src interface{}) error

Scan deserialises the object from raw database data

func (Languages) String

func (l Languages) String() string

String represents the languages as 2-letter codes separated by spaces

func (Languages) Value

func (l Languages) Value() (driver.Value, error)

Value serialises the object to raw database data

type MapStringStepStatus

type MapStringStepStatus map[string]*StepStatus

MapStringStepStatus is an instance of map[string]*StepStatus which implements the SQL Valuer and Scanner interfaces, so it can be stored in a database. Its SQL type should be blob.

func (MapStringStepStatus) For

For returns the status for the given step (key). Same as using [], but when the key is not found it fills it with a default status instead of returning nil

func (*MapStringStepStatus) Scan

func (m *MapStringStepStatus) Scan(src interface{}) error

Scan deserialises the object from raw database data

func (MapStringStepStatus) Value

func (m MapStringStepStatus) Value() (driver.Value, error)

Value serialises the object to raw database data

type MapStringString

type MapStringString map[string]string

MapStringString is an instance of map[string]string which implements the SQL Valuer and Scanner interfaces, so it can be stored in a database. Its SQL type should be integer.

func (*MapStringString) Scan

func (m *MapStringString) Scan(src interface{}) error

Scan deserialises the object from raw database data

func (MapStringString) Value

func (m MapStringString) Value() (driver.Value, error)

Value serialises the object to raw database data

type SliceString

type SliceString []string

SliceString is an instance of []string which implements the SQL Valuer and Scanner interfaces, so it can be stored in a database. Its SQL type should be blob.

func (*SliceString) Scan

func (m *SliceString) Scan(src interface{}) error

Scan deserialises the object from raw database data

func (SliceString) Value

func (m SliceString) Value() (driver.Value, error)

Value serialises the object to raw database data

type Status

type Status int

Status represents the state of an import step

const (
	// Incomplete objects haven't been imported yet
	Incomplete Status = iota
	// Skipped objects have been skipped by user action
	Skipped
	// Success objects have been imported correctly
	Success
	// Error objects have failed importing
	Error
)

func (Status) String

func (i Status) String() string

type StepStatus

type StepStatus struct {
	Status  Status `json:"status"`
	Message string `json:"message"`
}

StepStatus contains the state of an import state and a string message

func (*StepStatus) Errorf

func (m *StepStatus) Errorf(message string, arguments ...interface{})

Errorf sets the status to Error and writes a message

func (*StepStatus) Skip

func (m *StepStatus) Skip()

Skip sets the status to Skipped

func (*StepStatus) Succeed

func (m *StepStatus) Succeed()

Succeed sets the status to Success

type Template

type Template struct {
	template.Template
}

Template wraps a text template for generating strings

func MustParseTemplate

func MustParseTemplate(s string) *Template

MustParseTemplate creates a new template from the string and panics on failiure.

func ParseTemplate

func ParseTemplate(s string) (*Template, error)

ParseTemplate creates a new template from the string

func (*Template) On

func (t *Template) On(data interface{}) (string, error)

On performs the template on data

func (*Template) UnmarshalString

func (t *Template) UnmarshalString(s string) error

UnmarshalString parses the template from a string

func (*Template) UnmarshalText

func (t *Template) UnmarshalText(text []byte) error

UnmarshalText parses the template from text

Jump to

Keyboard shortcuts

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