utils

package
v0.0.0-...-ef069ef Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = logger.New()

Functions

func CmdInit

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

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

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

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

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

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 ReducedEnv

func ReducedEnv(addGoPath bool) []string

ReducedEnv returns a list of environment vairables by using os.Env it will remove the GOPATH, GOROOT if addGoPath is true

func RenderTemplate

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

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

func RenderTemplateToStream

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

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

func Retryf

func Retryf(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

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

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

func NewBuildError

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

Returns a new builed error.

func (*BuildError) Error

func (b *BuildError) Error() string

BuildError implements Error() string.

type Error

type Error string

Error is used for constant errors.

var (
	ErrNoApp   Error = "no app found"
	ErrNoRevel Error = "no revel found"
)

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

type LoggedError

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

func NewLoggedError

func NewLoggedError(err error) *LoggedError

type SourceError

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

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

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

func NewError

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

Return a new error object.

func (*SourceError) ContextSource

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

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

func (*SourceError) Error

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