util

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2017 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateField

func CreateField(name string, fieldType ast.Expr) *ast.Field

func CreateSourceCode

func CreateSourceCode(astFile *ast.File) ([]byte, error)

func DirToImport

func DirToImport(p string) (string, error)

DirToImport converts a directory path on the local machine to a Go import path (usually relative to the $GOPATH/src directory)

For example,

/Users/user/workspace/Go/github.com/mokiat/gostub

will be converted to

github.com/mokiat/gostub

should GOPATH include the location

/Users/user/workspace/Go

func EachDeclarationInFile

func EachDeclarationInFile(file *ast.File) <-chan ast.Decl

func EachFieldInFieldList

func EachFieldInFieldList(fieldList *ast.FieldList) <-chan *ast.Field

func EachGenericDeclarationInFile

func EachGenericDeclarationInFile(file *ast.File) <-chan *ast.GenDecl

func EachSpecificationInGenericDeclaration

func EachSpecificationInGenericDeclaration(decl *ast.GenDecl) <-chan ast.Spec

func EachTypeSpecificationInFile

func EachTypeSpecificationInFile(file *ast.File) <-chan *ast.TypeSpec

func EachTypeSpecificationInGenericDeclaration

func EachTypeSpecificationInGenericDeclaration(decl *ast.GenDecl) <-chan *ast.TypeSpec

func FieldTypeReuseCount

func FieldTypeReuseCount(field *ast.Field) int

func FieldsAsAnonymous

func FieldsAsAnonymous(fields []*ast.Field) []*ast.Field

func FieldsWithoutEllipsis

func FieldsWithoutEllipsis(fields []*ast.Field) []*ast.Field

func FixSourceCodeImports

func FixSourceCodeImports(original []byte) ([]byte, error)

func FormatSourceCode

func FormatSourceCode(original []byte) ([]byte, error)

func ImportToDir

func ImportToDir(imp string) (string, error)

ImportToDir converts an import location to a directory path on the local machine.

For example,

github.com/mokiat/gostub

will be converted to

/Users/user/workspace/Go/github.com/mokiat/gostub

should GOPATH be equal to

/Users/user/workspace/Go

func SaveSourceCode

func SaveSourceCode(filePath string, sourceCode []byte) error

func SnakeCase

func SnakeCase(text string) string

func ToPrivate

func ToPrivate(name string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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