1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package pkg
- import (
- "encoding/json"
- "strconv"
- "time"
- )
- func StringToInt(e string) (int, error) {
- return strconv.Atoi(e)
- }
- func GetCurrentTimeStr() string {
- return time.Now().Format("2006-01-02 15:04:05")
- }
- func GetCurrentTime() time.Time {
- return time.Now()
- }
- func CheckDateStr(date string) bool {
- if _, err := time.Parse("2006-01-02", date); err != nil {
- return false
- }
- return true
- }
- func StructToJsonStr(e interface{}) (string, error) {
- if b, err := json.Marshal(e); err == nil {
- return string(b), err
- } else {
- return "", err
- }
- }
- func IsEmptyStr(e string) bool {
- if e == "" {
- return true
- }
- return false
- }
|