Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayIncludeString(sl []string, v string, islike bool) bool
- func ContainsString(sl []string, v string) bool
- func ConvertChineseGender(gender string) string
- func CopyFile(src, dst string) error
- func CreateResponse(key string) map[string]interface{}
- func CreateResponseDesc(key, param, desc string) map[string]interface{}
- func CreateResponseParam(key string, param string) map[string]interface{}
- func Execute(cmdstr string, args ...string) (string, string, error)
- func ExecuteBackground(cmdstr string, args ...string) (int, error)
- func ExecuteHideWindow(cmdstr string, args ...string) (string, string, error)
- func ExecutionDir() string
- func GetFormatTimeString(t time.Time, format string) string
- func GetMacAddress() string
- func GetMimeType(contentType string) string
- func GetModuleLanguage() string
- func GetRandomString(length int) (rndtxt string)
- func GetRandomTempDirName(basePath string, length int) (rndtxt string)
- func GetSystemLanguage() string
- func HasString(sl []string, v string) bool
- func IsImage(filename string) bool
- func MatchDatePattern(date string) bool
- func PadLeft(str, pad string, length int) string
- func ReadJSONConfig(path string) (map[string]interface{}, error)
- func RemoveDuplicateString(slice []string) []string
- func RemoveSuffixVersion(name string) string
- func RocToADYear(rocDate string) string
- func SQLTimeFormatToString(t time.Time) string
- func SQLTimeStringToTime(t string) (time.Time, error)
- func SQLTimeStringToTimeUTCZero(t string) (time.Time, error)
- func SetModuleLanguage(langCode string) error
- func SetRequestBodyParams(body io.ReadCloser) (map[string]interface{}, error)
- func TimeStamptoTime(timeStampStr string) (time.Time, error)
- func ToRocDate(date string) string
- func WriteJSONConfig(path string, jsonMap map[string]interface{}) error
Constants ¶
const TimeLayout = "2006-01-02 15:04:05"
TimeLayout used to time.parse
Variables ¶
var ErrorCodeTable = map[string][]string{
"200.1": {"20001", "successful operation", "操作成功"},
"400.1": {"40001", "missing parameter: @param", "缺少參數 @param"},
"400.2": {"40002", "parameter type error: @param", "參數型別錯誤 @param"},
"400.3": {"40003", "parameter format error: @param", "參數格式錯誤 @param"},
"400.4": {"40004", "parameter structure error", "參數結構錯誤"},
"400.5": {"40005", "password and confirmed password dose not match", "密碼錯誤"},
"400.6": {"40006", atParameter, "時間區間參數安排錯誤"},
"400.7": {"40007", "pararameter's resource not found: @param", "找不到 @param"},
"401.1": {"40101", "authentication error@param", "登入認證失敗"},
"401.2": {"40102", "wrong password", "密碼錯誤"},
"401.3": {"40103", "login failed too many times, login prohibited ten minutes", "登入失敗太多次,暫時禁止登入十分鐘"},
"401.4": {"40104", "your device not certified to using this service", "您的裝置未被認證可使用此服務"},
"403.1": {"40301", "permission denied@param", "權限不足"},
"404.1": {"40401", "@param not found", "找不到 @param"},
"422.1": {"42201", "@param exists", "已定義 @param"},
"422.2": {"42202", atParameter, "MAC已經綁定金鑰"},
"500.1": {"50001", atParameter, "伺服器內部錯誤"},
"500.2": {"50002", atParameter, "資料庫錯誤"},
"500.3": {"50003", atParameter, "檔案上傳處理錯誤"},
"500.4": {"50004", atParameter, "送簽錯誤"},
"500.5": {"50005", atParameter, "呼叫HIS API錯誤"},
}
ErrorCodeTable record errror code and message for response
var ImageExtName = []string{".jpg", ".jpeg", ".png", ".bmp", ".gif"}
Functions ¶
func ContainsString ¶
ContainsString Contains find element slice contains the element or not
func ConvertChineseGender ¶
ConvertChineseGender convert "男", "女" to "M", "F"
func CreateResponse ¶
CreateResponse create response of web api
func CreateResponseDesc ¶ added in v0.2.2
CreateResponseDesc create response of web api with parameter & description
func CreateResponseParam ¶
CreateResponseParam create response of web api with parameter
func ExecuteBackground ¶
ExecuteBackground execute terminal's command in the background retrun pid, error
func ExecuteHideWindow ¶ added in v0.2.13
ExecuteHideWindow execute terminal's command and hide window retrun stdout, stderr & error
func ExecutionDir ¶
func ExecutionDir() string
func GetFormatTimeString ¶
GetFormatTimeString set time to fomrat string example: - input: (time.Now(),"YYYY-MM-DD hh:mm:ss") - output: "2019-10-17 15:30:46"
func GetMimeType ¶
GetMimeType get mimetype of file from *gin.Context.ContentType() example format of contentType: Content-Type:text/plain] multipart/form-data
func GetModuleLanguage ¶ added in v0.2.11
func GetModuleLanguage() string
func GetRandomString ¶
GetRandomString 取得指定長度的隨機字串,長度必需大於0小於等於100,否則會回傳空字串 ""
func GetRandomTempDirName ¶
GetRandomTempDirName 取得指定長度且不重複的暫存資料夾路徑
func GetSystemLanguage ¶ added in v0.2.11
func GetSystemLanguage() string
GetSystemLanguage get system's language setting
Only support for detecting the following languages: en, zh-Hant, zh-Hans. (The returned names refer to the List of ISO 639-1 codes) All other languages will be treated as English.
func MatchDatePattern ¶
MatchDatePattern check date string is match pattern "YYYY-MM-DD",ex:"2015-11-26"
func ReadJSONConfig ¶
func RemoveDuplicateString ¶ added in v0.2.10
func RemoveSuffixVersion ¶
func RocToADYear ¶
RocToADYear ROC YYYMMDD(or YYMMDD) format to AD YYYY-MM-DD format
func SQLTimeFormatToString ¶
SQLTimeFormatToString turn time to sql format time in string
func SQLTimeStringToTime ¶
SQLTimeStringToTime turn sql fromat time string to time type
func SQLTimeStringToTimeUTCZero ¶ added in v0.2.10
SQLTimeStringToTimeUTCZero turn sql fromat time string to time type and time zone is UTC+0
func SetModuleLanguage ¶ added in v0.2.11
SetModuleLanguage set module's language
Only support the following languages: en, zh-Hant, zh-Hans.
func SetRequestBodyParams ¶
func SetRequestBodyParams(body io.ReadCloser) (map[string]interface{}, error)
SetRequestBodyParams turn c.Request.Body ReaderCloser to params map[string]interface{}
func TimeStamptoTime ¶
TimeStamptoTime convert timestamp string to time
func WriteJSONConfig ¶
Types ¶
This section is empty.