add: email module

This commit is contained in:
2023-02-02 17:59:03 +08:00
parent 6466292524
commit a40ab2d218
8 changed files with 108 additions and 3 deletions
+33
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"strconv"
"time"
)
// IF 三元表达式
@@ -78,3 +79,35 @@ func IsFileOrDirExist(path string) bool {
}
return true
}
// ToJSONString 转json字符串
// v 对象, 非对象地址
func ToJSONString(v interface{}) string {
output, _ := json.Marshal(&v)
return string(output)
}
// ParseJSONStruct 解析json字符串
// jsonStr json字符串
// v 对象, 非对象地址
func ParseJSONStruct(jsonStr string, v interface{}) {
err := json.Unmarshal([]byte(jsonStr), &v)
if err != nil {
panic("JSON解析失败, " + err.Error())
}
}
// FormatDateTime 格式化日期时间
func FormatDateTime(date time.Time) string {
return date.Format("2006-01-02 15:04:05")
}
// FormatDate 格式化日期
func FormatDate(date time.Time) string {
return date.Format("2006-01-02")
}
// FormatTime 格式化时间
func FormatTime(date time.Time) string {
return date.Format("15:04:05")
}