Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToString(b []byte) string
- func Command(command string, a ...string) (output string, err error)
- func Deserialize(str string, m interface{}) error
- func DeserializeBytes(b []byte, m interface{}) error
- func Exists(dir string) bool
- func FindLower(a, b int) int
- func HTMLEscape(s string) string
- func MustCommand(command string, a ...string) (output string)
- func Random(n int) []byte
- func RandomString(n int) string
- func Serialize(m interface{}) (string, error)
- func SerializeBytes(m interface{}) ([]byte, error)
- func StringToBytes(s string) []byte
- type BufferPool
- type Cmd
- type ITick
- type Ticker
Constants ¶
const (
// ContentBINARY is the string of "application/octet-stream response headers
ContentBINARY = "application/octet-stream"
)
Variables ¶
var ( // ErrNoZip returns an error with message: 'While creating file '+filename'. It's not a zip' ErrNoZip = errors.New("While installing file '%s'. It's not a zip") // ErrFileOpen returns an error with message: 'While opening a file. Trace: +specific error' ErrFileOpen = errors.New("While opening a file. Trace: %s") // ErrFileCreate returns an error with message: 'While creating a file. Trace: +specific error' ErrFileCreate = errors.New("While creating a file. Trace: %s") // ErrFileRemove returns an error with message: 'While removing a file. Trace: +specific error' ErrFileRemove = errors.New("While removing a file. Trace: %s") // ErrFileCopy returns an error with message: 'While copying files. Trace: +specific error' ErrFileCopy = errors.New("While copying files. Trace: %s") // ErrFileDownload returns an error with message: 'While downloading from +specific url. Trace: +specific error' ErrFileDownload = errors.New("While downloading from %s. Trace: %s") // ErrDirCreate returns an error with message: 'Unable to create directory on '+root dir'. Trace: +specific error ErrDirCreate = errors.New("Unable to create directory on '%s'. Trace: %s") )
var (
// AssetsDirectory the path which iris saves some assets came from the internet ( used in iris control plugin (to download the html,css,js) and for iris command line tool to download the packages)
AssetsDirectory = ""
)
var ( // PathSeparator is the string of os.PathSeparator PathSeparator = string(os.PathSeparator) )
Functions ¶
func BytesToString ¶
BytesToString accepts bytes and returns their string presentation instead of string() this method doesn't generate memory allocations, BUT it is not safe to use anywhere because it points this helps on 0 memory allocations
func Deserialize ¶
Deserialize accepts an encoded string and a data struct which will be filled with the desierialized string using gob decoder
func DeserializeBytes ¶
DeserializeBytes converts the bytes to an object using gob decoder
func HTMLEscape ¶
HTMLEscape returns a string which has no valid html code
func MustCommand ¶
MustCommand executes a command in shell and returns it's output, it's block version. It panics on an error
func Random ¶
Random takes a parameter (int) and returns random slice of byte ex: var randomstrbytes []byte; randomstrbytes = utils.Random(32)
func RandomString ¶
RandomString accepts a number(10 for example) and returns a random string using simple but fairly safe random algorithm
func Serialize ¶
Serialize serialize any type to gob bytes and after returns its the base64 encoded string
func SerializeBytes ¶
SerializeBytes serializa bytes using gob encoder and returns them
func StringToBytes ¶
StringToBytes accepts string and returns their []byte presentation instead of byte() this method doesn't generate memory allocations, BUT it is not safe to use anywhere because it points this helps on 0 memory allocations
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 ¶
Cmd is a custom struch which 'implements' the *exec.Cmd
func CommandBuilder ¶
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 ¶
AppendArguments appends the arguments to the exists
func (*Cmd) Arguments ¶
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 ¶
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 ¶
ResetArguments resets the arguments
type ITick ¶
type ITick interface {
OnTick()
}
ITick is the interface which all ticker's listeners must implement
type Ticker ¶
type Ticker struct {
// contains filtered or unexported fields
}
Ticker is the timer which is used in cache
func (*Ticker) OnTick ¶
func (c *Ticker) OnTick(h func())
OnTick add event handlers/ callbacks which are called on each timer's tick