Documentation
¶
Index ¶
- Constants
- Variables
- func BackupTable(tableName string, v interface{}, db *gorm.DB, savePath string, version string) error
- func DigitCaptchaGen() (string, string, error)
- func DigitCaptchaVerify(id string, answer string) bool
- func DumpDatabase(host, username, password, dbName, tableName, savePath, version string, ...) error
- func EnsureOpenFile(full string) (*os.File, error)
- func EnsurePath(path string) error
- func ErrPanic(err error)
- func Md5(data []byte) string
- func MemSet(p unsafe.Pointer, b byte, length uintptr)
- func RandInt(max int) int
- func RandIntScope(from, to int) int
- func RandNumAlphaString(length int) string
- func RandNumString(length int) string
- func RestoreTable(filefull string, v interface{}, db *gorm.DB) error
- func Sha1(data []byte) string
- func Sha256(data []byte) string
- func TarGz(src, dest string) error
- func UnTarGz(tarGz, dest string) error
- func UnZip(zipFile, destPath string) error
- func Unused(v ...interface{})
- func ValidPhoneCN(phone string) bool
- func ValidPhoneCNSimple(phone string) bool
- func Zip(fileOrDir, destFile string) error
- type Time
Constants ¶
View Source
const (
TIME_FORMAT = "2006-01-02 15:04:05"
)
Variables ¶
View Source
var ( ErrPathIsNotAPath = errors.New("Not a path") ErrPathPerm = errors.New("User has not perm to path") )
View Source
var (
CHAR_POOL = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
Functions ¶
func BackupTable ¶
func BackupTable(tableName string, v interface{}, db *gorm.DB, savePath string, version string) error
* Backup MySQL table rows into json file
@tableName: tableName, is not used for quering rows but as a part of json filename @v: slice pointer used for gorm resultset, this is where to implement generic type function @savePath: directory of where exported file located. @version: version of exporting. used as a part of the json filename
func DigitCaptchaGen ¶
func DigitCaptchaVerify ¶
func DumpDatabase ¶
func DumpDatabase(host, username, password, dbName, tableName, savePath, version string, port int) error
* Backup Database(or single table in it) using 'mysqldump' which must be pre-installed.
NOTICE: this function will block until done. You're able to delete 'cmd.Wait()' if you dont care the result and want a async execution, and mostly which is OKay.
func RandIntScope ¶
func RandNumAlphaString ¶
func RandNumString ¶
func RestoreTable ¶
TODO batch insertion
func ValidPhoneCN ¶
func ValidPhoneCNSimple ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.