utils

package
v1.99.6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = logger.New()
View Source
var NO_APP_FOUND = errors.New("No app found")
View Source
var NO_REVEL_FOUND = errors.New("No revel found")

Functions

func CmdInit added in v0.20.1

func CmdInit(c *exec.Cmd, addGoPath bool, basePath string)

Initialize the command based on the GO environment

func ContainsString

func ContainsString(list []string, target string) bool

Return true if the target string is in the list

func CopyDir added in v0.20.1

func CopyDir(destDir, srcDir string, data map[string]interface{}) error

copyDir copies a directory tree over to a new directory. Any files ending in ".template" are treated as a Go template and rendered using the given data. Additionally, the trailing ".template" is stripped from the file name. Also, dot files and dot directories are skipped.

func CopyFile added in v0.20.1

func CopyFile(destFilename, srcFilename string) (err error)

Copy file returns error

func DirExists

func DirExists(filename string) bool

DirExists returns true if the given path exists and is a directory.

func Empty

func Empty(dirname string) bool

empty returns true if the given directory is empty. the directory must exist.

func Exists

func Exists(filename string) bool

Return true if the file exists

func FindSrcPaths added in v0.20.1

func FindSrcPaths(appPath string, packageList []string, packageResolver func(pkgName string) error) (sourcePathsmap map[string]string, err error)

Find the full source dir for the import path, uses the build.Default.GOPATH to search for the directory

func GenerateTemplate added in v0.20.1

func GenerateTemplate(filename, templateSource string, args map[string]interface{}) (err error)

GenerateTemplate renders the given template to produce source code, which it writes to the given file.

func InitLogger

func InitLogger(basePath string, logLevel logger.LogLevel)

func MustChmod

func MustChmod(filename string, mode os.FileMode)

func MustReadLines

func MustReadLines(filename string) []string

MustReadLines reads the lines of the given file. Panics in the case of error.

func NewBuildIfError added in v0.20.1

func NewBuildIfError(err error, message string, args ...interface{}) (b error)

Returns a new BuildError if err is not nil

func PanicOnError

func PanicOnError(err error, msg string)

Called if panic

func ReadLines

func ReadLines(filename string) ([]string, error)

ReadLines reads the lines of the given file. Panics in the case of error.

func RenderTemplate added in v0.20.1

func RenderTemplate(destPath, srcPath string, data interface{}) (err error)

Given the target path and source path and data. A template

func RenderTemplateToStream added in v0.20.1

func RenderTemplateToStream(output io.Writer, srcPath []string, data interface{}) (err error)

Given the target path and source path and data. A template

func Retry

func Retry(format string, args ...interface{})

This function is to throw a panic that may be caught by the packger so it can perform the needed imports

func TarGzDir added in v0.20.1

func TarGzDir(destFilename, srcDir string) (name string, err error)

Tar gz the folder

func Walk

func Walk(root string, walkFn filepath.WalkFunc) error

Shortcut to fsWalk

Types

type BuildError added in v0.20.1

type BuildError struct {
	Stack   interface{}
	Message string
	Args    []interface{}
}

func NewBuildError added in v0.20.1

func NewBuildError(message string, args ...interface{}) (b *BuildError)

Returns a new builed error

func (*BuildError) Error added in v0.20.1

func (b *BuildError) Error() string

BuildError implements Error() string

type LoggedError

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

func NewLoggedError

func NewLoggedError(err error) *LoggedError

type SourceError added in v1.99.4

type SourceError struct {
	SourceType               string   // The type of source that failed to build.
	Title, Path, Description string   // Description of the error, as presented to the user.
	Line, Column             int      // Where the error was encountered.
	SourceLines              []string // The entire source file, split into lines.
	Stack                    string   // The raw stack trace string from debug.Stack().
	MetaError                string   // Error that occurred producing the error page.
	Link                     string   // A configurable link to wrap the error source in
}

The error is a wrapper for the

func NewCompileError added in v1.99.4

func NewCompileError(importPath, errorLink string, error error) *SourceError

Parse the output of the "go build" command. Return a detailed Error.

func NewError added in v0.21.0

func NewError(source, title, path, description string) *SourceError

Return a new error object

func (*SourceError) ContextSource added in v1.99.4

func (e *SourceError) ContextSource() []SourceLine

ContextSource method returns a snippet of the source around where the error occurred.

func (*SourceError) Error added in v1.99.4

func (e *SourceError) Error() string

Error method constructs a plaintext version of the error, taking account that fields are optionally set. Returns e.g. Compilation Error (in views/header.html:51): expected right delim in end; got "}"

func (e *SourceError) SetLink(errorLink string)

Creates a link based on the configuration setting "errors.link"

type SourceLine

type SourceLine struct {
	Source  string
	Line    int
	IsError bool
}

The error is a wrapper for the

Jump to

Keyboard shortcuts

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