attrs

package module
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 3 Imported by: 88

README

attrs

GoDoc

Requirements
  • Go 1.13+
  • Go Modules
Installation
$ go get github.com/gobuffalo/attrs/cmd/attrs

Documentation

Index

Constants

View Source
const Version = "v0.1.0"

Version of attrs

Variables

View Source
var ErrMissingName = errors.New("requires a name argument")
View Source
var ErrRepeatedAttr = errors.New("duplicate attr name")

ErrRepeatedAttr is returned when parsing an array with repeated names

Functions

This section is empty.

Types

type Attr

type Attr struct {
	Original string
	Name     name.Ident
	// contains filtered or unexported fields
}

Attr is buffalo's implementation for model attributes

func Parse

func Parse(arg string) (Attr, error)

Parse takes a string like name:commonType:goType and turns it into an Attr

func (Attr) CommonType

func (a Attr) CommonType() string

CommonType returns the common type of an attribute, this common type is used later for things like determining the database column type depending on the database.

func (Attr) GoType

func (a Attr) GoType() string

GoType returns the Go type for an Attr based on its commonType

func (Attr) String

func (a Attr) String() string

type Attrs

type Attrs []Attr

Attrs is a slice of Attr

func ParseArgs

func ParseArgs(args ...string) (Attrs, error)

ParseArgs parses passed string args into Attrs

func (Attrs) Slice

func (ats Attrs) Slice() []string

type NamedAttrs

type NamedAttrs struct {
	Name  name.Ident
	Attrs Attrs
}

func ParseNamedArgs

func ParseNamedArgs(args ...string) (NamedAttrs, error)

func (NamedAttrs) String

func (n NamedAttrs) String() string

func (NamedAttrs) Validate

func (n NamedAttrs) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL