utils

package
v0.0.0-...-b6a1298 Latest Latest
Warning

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

Go to latest
Published: May 17, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FilterPkgImports = struct {
	ByPath func(string) func(PkgImport) bool
	ByID   func(string) func(PkgImport) bool
}{
	ByPath: func(v string) func(PkgImport) bool { return func(o PkgImport) bool { return o.Path == v } },
	ByID:   func(v string) func(PkgImport) bool { return func(o PkgImport) bool { return o.ID == v } },
}

FilterPkgImports provides filters for a struct.

Functions

func GetPkgToLoad

func GetPkgToLoad() string

GetPkgToLoad return the package to load

Types

type FileOut

type FileOut struct {
	GeneratorName string
	PkgName       string
	Path          string
	Body          bytes.Buffer
	Imports       PkgImports
}

FileOut ...

func (*FileOut) AddImport

func (f *FileOut) AddImport(path, id string)

AddImport add new imports

func (*FileOut) Write

func (f *FileOut) Write() error

type FilesOut

type FilesOut struct {
	Files         []*FileOut
	GeneratorName string
}

FilesOut ...

func NewFilesOut

func NewFilesOut(name string) *FilesOut

NewFilesOut ...

func (*FilesOut) Get

func (f *FilesOut) Get(s string) *FileOut

Get the file handler matching path s

func (*FilesOut) Write

func (f *FilesOut) Write(to string)

type PkgImport

type PkgImport struct {
	Path string
	ID   string
}

PkgImport represents an import

func (PkgImport) GetID

func (t PkgImport) GetID() string

GetID of a PkgImport

func (PkgImport) String

func (t PkgImport) String() string

type PkgImports

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

PkgImports implements a typed slice of PkgImport

func NewPkgImports

func NewPkgImports() *PkgImports

NewPkgImports creates a new typed slice of PkgImport

func (*PkgImports) At

func (t *PkgImports) At(i int) PkgImport

At return the item at index i.

func (*PkgImports) Contains

func (t *PkgImports) Contains(s PkgImport) bool

Contains returns true if s in is t.

func (*PkgImports) Empty

func (t *PkgImports) Empty() bool

Empty returns true if the slice is empty.

func (*PkgImports) Filter

func (t *PkgImports) Filter(filters ...func(PkgImport) bool) *PkgImports

Filter return a new PkgImports with all items satisfying f.

func (*PkgImports) First

func (t *PkgImports) First() PkgImport

First returns the first value or default.

func (*PkgImports) Get

func (t *PkgImports) Get() []PkgImport

Get the slice.

func (*PkgImports) Index

func (t *PkgImports) Index(s PkgImport) int

Index of given PkgImport. It must implements Ider interface.

func (*PkgImports) InsertAt

func (t *PkgImports) InsertAt(i int, s PkgImport) *PkgImports

InsertAt adds given PkgImport at index i

func (*PkgImports) Last

func (t *PkgImports) Last() PkgImport

Last returns the last value or default.

func (*PkgImports) Len

func (t *PkgImports) Len() int

Len of the slice.

func (*PkgImports) Map

func (t *PkgImports) Map(mappers ...func(PkgImport) PkgImport) *PkgImports

Map return a new PkgImports of each items modified by f.

func (*PkgImports) Pop

func (t *PkgImports) Pop() PkgImport

Pop removes then returns the last PkgImport.

func (*PkgImports) Push

func (t *PkgImports) Push(x ...PkgImport) *PkgImports

Push appends every PkgImport

func (*PkgImports) Remove

func (t *PkgImports) Remove(s PkgImport) bool

Remove removes given PkgImport

func (*PkgImports) RemoveAt

func (t *PkgImports) RemoveAt(i int) bool

RemoveAt removes a PkgImport at index i.

func (*PkgImports) Reverse

func (t *PkgImports) Reverse() *PkgImports

Reverse the slice.

func (*PkgImports) Set

func (t *PkgImports) Set(x []PkgImport) *PkgImports

Set the slice.

func (*PkgImports) Shift

func (t *PkgImports) Shift() PkgImport

Shift removes then returns the first PkgImport.

func (*PkgImports) Slice

func (t *PkgImports) Slice(start int, length int) []PkgImport

Slice returns a copied slice of PkgImport, starting at start, ending at start+length.

func (*PkgImports) Splice

func (t *PkgImports) Splice(start int, length int, s ...PkgImport) []PkgImport

Splice removes and returns a slice of PkgImport, starting at start, ending at start+length. If any s is provided, they are inserted in place of the removed slice.

func (*PkgImports) Unshift

func (t *PkgImports) Unshift(x ...PkgImport) *PkgImports

Unshift prepends every PkgImport

type TransformArg

type TransformArg struct {
	FromPkgPath  string
	FromTypeName string
	ToPkgPath    string
	ToTypeName   string
	ToPath       string
}

TransformArg is a parsed cli arg.

func (TransformArg) String

func (t TransformArg) String() string

type TransformArgs

type TransformArgs struct {
	PkgBase string
	Args    []TransformArg
}

TransformArgs parse cli args.

func NewTransformsArgs

func NewTransformsArgs(outPkg string) TransformArgs

NewTransformsArgs ...

func (TransformArgs) Parse

func (t TransformArgs) Parse(args []string) (TransformArgs, error)

Parse cli arguments.

Jump to

Keyboard shortcuts

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