utils

package
v5.0.0-...-c598e7b Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2017 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentBINARY is the  string of "application/octet-stream response headers
	ContentBINARY = "application/octet-stream"
)

Variables

View Source
var (
	// AssetsDirectory is the path which iris saves some assets came from the internet used mostly from iris control plugin (to download the html,css,js)
	AssetsDirectory = ""
)
View Source
var (
	// PathSeparator is the string of os.PathSeparator
	PathSeparator = string(os.PathSeparator)
)

Functions

func Command

func Command(command string, a ...string) (output string, err error)

Command executes a command in shell and returns it's output, it's block version

func Exists

func Exists(dir string) bool

Exists returns true if directory||file exists

func MustCommand

func MustCommand(command string, a ...string) (output string)

MustCommand executes a command in shell and returns it's output, it's block version. It panics on an error

Types

type BufferPool

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

BufferPool implements a pool of bytes.Buffers in the form of a bounded channel. Pulled from the github.com/oxtoacart/bpool package (Apache licensed).

func NewBufferPool

func NewBufferPool(size int) (bp *BufferPool)

NewBufferPool creates a new BufferPool bounded to the given size.

func (*BufferPool) Get

func (bp *BufferPool) Get() (b *bytes.Buffer)

Get gets a Buffer from the BufferPool, or creates a new one if none are available in the pool.

func (*BufferPool) Put

func (bp *BufferPool) Put(b *bytes.Buffer)

Put returns the given Buffer to the BufferPool.

type Cmd

type Cmd struct {
	*exec.Cmd
}

Cmd is a custom struch which 'implements' the *exec.Cmd

func CommandBuilder

func CommandBuilder(command string, args ...string) *Cmd

CommandBuilder creates a Cmd object and returns it accepts 2 parameters, one is optionally first parameter is the command (string) second variatic parameter is the argument(s) (slice of string)

the difference from the normal Command function is that you can re-use this Cmd, it doesn't execute until you call its Command function

func (*Cmd) AppendArguments

func (cmd *Cmd) AppendArguments(args ...string) *Cmd

AppendArguments appends the arguments to the exists

func (*Cmd) Arguments

func (cmd *Cmd) Arguments(args ...string) *Cmd

Arguments sets the command line arguments, including the command as Args[0]. If the args parameter is empty or nil, Run uses {Path}.

In typical use, both Path and args are set by calling Command.

func (*Cmd) Directory

func (cmd *Cmd) Directory(workingDirectory string) *Cmd

Directory sets the working directory of the command. If workingDirectory is the empty string, Run runs the command in the calling process's current directory.

func (*Cmd) ResetArguments

func (cmd *Cmd) ResetArguments() *Cmd

ResetArguments resets the arguments

Jump to

Keyboard shortcuts

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