Documentation ¶
Overview ¶
Package gulu implements some common utilities.
Index ¶
- Constants
- Variables
- type GuluFile
- func (*GuluFile) CopyDir(source string, dest string) (err error)
- func (*GuluFile) CopyFile(source string, dest string) (err error)
- func (*GuluFile) GetFileSize(path string) int64
- func (*GuluFile) IsBinary(content string) bool
- func (*GuluFile) IsDir(path string) bool
- func (*GuluFile) IsExist(path string) bool
- func (*GuluFile) IsImg(extension string) bool
- type GuluGo
- type GuluNet
- type GuluOS
- type GuluPanic
- type GuluRand
- type GuluRet
- func (*GuluRet) NewResult() *Result
- func (*GuluRet) RetGzJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{})
- func (*GuluRet) RetGzResult(w http.ResponseWriter, r *http.Request, res *Result)
- func (*GuluRet) RetJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{})
- func (*GuluRet) RetResult(w http.ResponseWriter, r *http.Request, res *Result)
- type GuluRune
- type GuluStr
- type GuluZip
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) IsDebugEnabled() bool
- func (l *Logger) IsTraceEnabled() bool
- func (l *Logger) IsWarnEnabled() bool
- func (l *Logger) SetLevel(level string)
- func (l *Logger) Trace(v ...interface{})
- func (l *Logger) Tracef(format string, v ...interface{})
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- type Result
- type ZipFile
Constants ¶
const ( Off = iota Trace Debug Info Warn Error Fatal )
Logging level.
const Version = "v1.0.0"
Version is the version of Gulu.
Variables ¶
var ( // File utilities File GuluFile // Go utilities Go GuluGo // Net utilities Net GuluNet // OS utilities OS GuluOS // Panic utilities Panic GuluPanic // Rand utilities Rand GuluRand // Ret utilities Ret GuluRet // Rune utilities Rune GuluRune // Str utilities Str GuluStr // Zip utilities Zip GuluZip )
var Log = guluLog{}
Log utilities.
Functions ¶
This section is empty.
Types ¶
type GuluFile ¶
type GuluFile byte
GuluFile is the receiver of file utilities
func (*GuluFile) GetFileSize ¶
GetFileSize get the length in bytes of file of the specified path.
func (*GuluFile) IsBinary ¶
IsBinary determines whether the specified content is a binary file content.
type GuluGo ¶
type GuluGo byte
GuluGo is the receiver of Go utilities
func (*GuluGo) GetAPIPath ¶
GetAPIPath gets the Go source code path $GOROOT/src.
func (*GuluGo) GetExecutableInGOBIN ¶
GetExecutableInGOBIN gets executable file under GOBIN path.
The specified executable should not with extension, this function will append .exe if on Windows.
func (*GuluGo) GetGoFormats ¶
GetGoFormats gets Go format tools. It may return ["gofmt", "goimports"].
type GuluNet ¶
type GuluNet byte
GuluNet is the receiver of network utilities
type GuluOS ¶
type GuluOS byte
GuluOS is the receiver of OS utilities
func (*GuluOS) Home ¶
Home returns the home directory for the executing user.
This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.
type GuluRand ¶
type GuluRand byte
GuluRand is the receiver of random utilities
type GuluRet ¶
type GuluRet byte
GuluRet is the receiver of result utilities
func (*GuluRet) RetGzJSON ¶
RetGzJSON writes HTTP response with "Content-Type, application/json" and "Content-Encoding, gzip".
func (*GuluRet) RetGzResult ¶
RetGzResult writes HTTP response with "Content-Type, application/json" and "Content-Encoding, gzip".
type GuluRune ¶
type GuluRune byte
GuluRune is the receiver of rune utilities
func (*GuluRune) IsNumOrLetter ¶
IsNumOrLetter checks the specified rune is number or letter.
type GuluStr ¶
type GuluStr byte
GuluStr is the receiver of string utilities
func (*GuluStr) LCS ¶
LCS gets the longest common substring of s1 and s2.
Refers to http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring.
type GuluZip ¶
type GuluZip byte
GuluZip is the receiver of zip utilities
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a simple logger with level. The underlying logger is the standard Go logging "log".
func (*Logger) Fatal ¶
func (l *Logger) Fatal(v ...interface{})
Fatal prints fatal level message and exit process with code 1.
func (*Logger) IsDebugEnabled ¶
IsDebugEnabled determines whether the debug level is enabled.
func (*Logger) IsTraceEnabled ¶
IsTraceEnabled determines whether the trace level is enabled.
func (*Logger) IsWarnEnabled ¶
IsWarnEnabled determines whether the debug level is enabled.
type Result ¶
type Result struct { Code int `json:"code"` // return code Msg string `json:"msg"` // message Data interface{} `json:"data"` // data object }
Result represents a common-used result struct.
type ZipFile ¶
type ZipFile struct {
// contains filtered or unexported fields
}
ZipFile represents a zip file.
func (*ZipFile) AddDirectory ¶
AddDirectory adds a directory.
func (*ZipFile) AddDirectoryN ¶
AddDirectoryN adds directories.