Documentation ¶
Index ¶
- Constants
- Variables
- func CWD() string
- func CloseLogWriter()
- func Conf() *ini.File
- func ConfFile() string
- func ConfFileDev() string
- func Copy(src, dest string) error
- func DBFile() string
- func DBFileDev() string
- func DataDir() string
- func DeepCopy(dst, src interface{}) error
- func EXEName() string
- func Ellipsis(text string, length int) string
- func EnsureDir(dir string) (err error)
- func ErrorLogFilename() string
- func Exist(path string) bool
- func ExpandHomeDir(path string) string
- func GetLogWriter() io.Writer
- func GetRequestHostname(r *http.Request) (hostname string)
- func GetRequestHref(r *http.Request) string
- func HasChinese(str string) bool
- func HomeDir() string
- func IsPortInUse(port int) bool
- func LocalIP() string
- func Log(msg ...interface{})
- func LogDir() string
- func Logf(format string, msg ...interface{})
- func MD5(str string) string
- func Open(url string) error
- func PauseExit()
- func PauseGo(msg ...interface{})
- func RedirectStderr() (err error)
- func ReloadConf() *ini.File
- func SaveToConf(section string, kvmap map[string]string) error
- func ShortID() string
- func UpTime() time.Duration
- func UpTimeString() string
- func WorkInDir(f func(), dir string)
- type DateTime
- type GormLogger
- type PageForm
- type PageResult
- type StatikFileSystem
- type StringArray
Constants ¶
View Source
const ( DateLayout = "2006-01-02" DateTimeLayout = "2006-01-02 15:04:05" BuildTimeLayout = "2006.0102.150405" TimestampLayout = "20060102150405" )
Variables ¶
View Source
var Debug = true
View Source
var (
DefaultGormLogger = GormLogger{log.New(os.Stdout, "[ORM] ", 0)}
)
View Source
var FlagVarConfFile string
View Source
var FlagVarDBFile string
View Source
var LogFormatter = func(values ...interface{}) (messages []interface{}) { if len(values) > 1 { var ( sql string formattedValues []string level = values[0] currentTime = time.Now().Format("2006/01/02 15:04:05") ) messages = []interface{}{currentTime} if level == "sql" { messages = append(messages, fmt.Sprintf("[%.2fms]", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0)) for _, value := range values[4].([]interface{}) { indirectValue := reflect.Indirect(reflect.ValueOf(value)) if indirectValue.IsValid() { value = indirectValue.Interface() if t, ok := value.(time.Time); ok { formattedValues = append(formattedValues, fmt.Sprintf("'%v'", t.Format("2006-01-02 15:04:05"))) } else if b, ok := value.([]byte); ok { if str := string(b); isPrintable(str) { formattedValues = append(formattedValues, fmt.Sprintf("'%v'", str)) } else { formattedValues = append(formattedValues, "'<binary>'") } } else if r, ok := value.(driver.Valuer); ok { if value, err := r.Value(); err == nil && value != nil { formattedValues = append(formattedValues, fmt.Sprintf("'%v'", value)) } else { formattedValues = append(formattedValues, "NULL") } } else { formattedValues = append(formattedValues, fmt.Sprintf("'%v'", value)) } } else { formattedValues = append(formattedValues, "NULL") } } if numericPlaceHolderRegexp.MatchString(values[3].(string)) { sql = values[3].(string) for index, value := range formattedValues { placeholder := fmt.Sprintf(`\$%d([^\d]|$)`, index+1) sql = regexp.MustCompile(placeholder).ReplaceAllString(sql, value+"$1") } } else { formattedValuesLength := len(formattedValues) for index, value := range sqlRegexp.Split(values[3].(string), -1) { sql += value if index < formattedValuesLength { sql += formattedValues[index] } } } messages = append(messages, sql) messages = append(messages, fmt.Sprintf("\r\n%v", strconv.FormatInt(values[5].(int64), 10)+" rows affected or returned")) } else { messages = append(messages, values[2:]...) } } return }
View Source
var StartTime = time.Now()
Functions ¶
func CloseLogWriter ¶
func CloseLogWriter()
func ConfFileDev ¶
func ConfFileDev() string
func ErrorLogFilename ¶
func ErrorLogFilename() string
func ExpandHomeDir ¶
func GetLogWriter ¶
func GetRequestHostname ¶
func GetRequestHref ¶
func HasChinese ¶
func IsPortInUse ¶
func ReloadConf ¶
func UpTimeString ¶
func UpTimeString() string
Types ¶
type GormLogger ¶
Logger default logger
func (GormLogger) Print ¶
func (logger GormLogger) Print(values ...interface{})
Print format & print log
type PageForm ¶
type PageForm struct { Start int `form:"start"` Limit int `form:"limit"` Q string `form:"q"` Sort string `form:"sort"` Order string `form:"order"` }
func NewPageForm ¶
func NewPageForm() *PageForm
type PageResult ¶
type PageResult struct { Total int `json:"total"` Rows interface{} `json:"rows"` }
func NewPageResult ¶
func NewPageResult(rows interface{}) *PageResult
func (*PageResult) Slice ¶
func (pr *PageResult) Slice(start, limit int) *PageResult
func (*PageResult) Sort ¶
func (pr *PageResult) Sort(by, order string) *PageResult
type StatikFileSystem ¶
type StatikFileSystem struct {
http.FileSystem
}
type StringArray ¶
type StringArray string
func (StringArray) MarshalJSON ¶
func (r StringArray) MarshalJSON() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.