util

package
v1.0.1-0...-540a35a Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowCORS

func AllowCORS(writer http.ResponseWriter)

allow cors.

func ConvertDateTimeStringToTime

func ConvertDateTimeStringToTime(timeString string) time.Time

convert time string(yyyy-MM-dd HH:mm:ss) to Time object

func ConvertTimeToDateString

func ConvertTimeToDateString(time time.Time) string

convert Time object to string(yyyy-MM-dd)

func ConvertTimeToDateTimeString

func ConvertTimeToDateTimeString(time time.Time) string

convert Time object to string(yyyy-MM-dd HH:mm:ss)

func ConvertTimeToTimeString

func ConvertTimeToTimeString(time time.Time) string

convert Time object to string(HH:mm:ss)

func CopyFile

func CopyFile(srcPath string, destPath string) (nBytes int64)

copy file

func DeleteEmptyDir

func DeleteEmptyDir(dirPath string) bool

try to delete empty dir. true: delete an empty dir, false: delete nothing.

func DeleteEmptyDirRecursive

func DeleteEmptyDirRecursive(dirPath string)

delete empty dir recursive, delete until not empty.

func DisableCache

func DisableCache(writer http.ResponseWriter)

disable cache.

func EnvDevelopment

func EnvDevelopment() bool

whether develop environment (whether run in IDE)

func EnvMacDevelopment

func EnvMacDevelopment() bool

whether mac develop environment

func EnvWinDevelopment

func EnvWinDevelopment() bool

whether windows develop environment

func FirstMinuteOfDay

func FirstMinuteOfDay(day time.Time) time.Time

func FirstSecondOfDay

func FirstSecondOfDay(day time.Time) time.Time

func GetBcrypt

func GetBcrypt(raw string) string

func GetConfPath

func GetConfPath() string

get conf path.

func GetDevHomePath

func GetDevHomePath() string

get development home path.

func GetDirOfPath

func GetDirOfPath(fullPath string) string

eg /var/www/xx.log -> /var/www

func GetExtension

func GetExtension(filename string) string

get extension by name. lowercase.

func GetFallbackMimeType

func GetFallbackMimeType(filename string, fallback string) string

get MimeType by filename, if not found return fallback.

func GetFilenameOfPath

func GetFilenameOfPath(fullPath string) string

get filename from path. eg /var/www/xx.log -> xx.log

func GetGoPath

func GetGoPath() string

func GetHomePath

func GetHomePath() string

get home path for application.

func GetHostFromRequest

func GetHostFromRequest(request *http.Request) string

get host from request

func GetHtmlPath

func GetHtmlPath() string

get html path dev: return $project/build/html prod: return $application/html

func GetIpAddress

func GetIpAddress(r *http.Request) string

get ip from request

func GetLogPath

func GetLogPath() string

get log path.

func GetMd5

func GetMd5(raw string) string

md5

func GetMimeType

func GetMimeType(filename string) string

get MimeType by filename, if not found return "application/octet-stream"

func GetMysqlUrl

func GetMysqlUrl(
	mysqlPort int,
	mysqlHost string,
	mysqlSchema string,
	mysqlUsername string,
	mysqlPassword string) string

get mysql url.

func GetSessionUuidFromRequest

func GetSessionUuidFromRequest(request *http.Request, cookieAuthKey string) string

get cookieAuthKey from request.

func GetSimpleFileName

func GetSimpleFileName(filename string) string

get filename without extension

func HumanFileSize

func HumanFileSize(bytes int64) string

human readable file size

func LastSecondOfDay

func LastSecondOfDay(day time.Time) time.Time

func MakeDirAll

func MakeDirAll(dirPath string) string

if directory not exit, create it.

func MatchBcrypt

func MatchBcrypt(raw string, bcryptStr string) bool

func PathExists

func PathExists(path string) bool

func RandomNumber4

func RandomNumber4() string

get random number 4.

func RandomString4

func RandomString4() string

get random 4 string

func Tomorrow

func Tomorrow() time.Time

Tomorrow right now

func UniformPath

func UniformPath(p string) string

1. replace \\ to / 2. clean path. 3. trim suffix /

func Yesterday

func Yesterday() time.Time

Yesterday right now

func Zip

func Zip(srcPath string, destPath string) error

zip srcPath to destPath。

Types

This section is empty.

Jump to

Keyboard shortcuts

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