utils

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = logger.New()

Functions

func ContainsString

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

Return true if the target string is in the list

func DirExists

func DirExists(filename string) bool

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

func ImportPathFromCurrentDir

func ImportPathFromCurrentDir() string

func InitLogger

func InitLogger(basePath string, logLevel logger.LogLevel)

func MustChmod

func MustChmod(filename string, mode os.FileMode)

func MustCopyDir

func MustCopyDir(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 MustCopyFile

func MustCopyFile(destFilename, srcFilename string)

func MustGenerateTemplate

func MustGenerateTemplate(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 MustReadLines

func MustReadLines(filename string) []string

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

func MustRenderTemplate

func MustRenderTemplate(destPath, srcPath string, data interface{})

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

func MustRenderTemplateToStream

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

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

func MustTarGzDir

func MustTarGzDir(destFilename, srcDir string) string

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 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 Walk

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

Types

type Error

type Error 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 (*Error) ContextSource

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

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

func (*Error) Error

func (e *Error) 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 *Error) SetLink(errorLink string)

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

type LoggedError

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

func NewLoggedError

func NewLoggedError(err error) *LoggedError

type SourceLine

type SourceLine struct {
	Source  string
	Line    int
	IsError bool
}

SourceLine structure to hold the per-source-line details.

Jump to

Keyboard shortcuts

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