You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
|
4 years ago
|
package common
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/unrolled/render"
|
||
|
|
)
|
||
|
|
|
||
|
|
var timeLayout = "2006-01-02 15:04:05" //转化所需模板
|
||
|
|
|
||
|
|
func MapOut() (data map[string]interface{}) {
|
||
|
|
data = make(map[string]interface{}) //必可不少,分配内存
|
||
|
|
return data
|
||
|
|
}
|
||
|
|
|
||
|
|
func MapOutint() (data map[int]interface{}) {
|
||
|
|
data = make(map[int]interface{}) //必可不少,分配内存
|
||
|
|
return data
|
||
|
|
}
|
||
|
|
func MapOutint64() (data map[int64]interface{}) {
|
||
|
|
data = make(map[int64]interface{}) //必可不少,分配内存
|
||
|
|
return data
|
||
|
|
}
|
||
|
|
func MapOutFloat64() (data map[float64]interface{}) {
|
||
|
|
data = make(map[float64]interface{}) //必可不少,分配内存
|
||
|
|
return data
|
||
|
|
}
|
||
|
|
|
||
|
|
func OutPutJson(out_val JsonOut) http.HandlerFunc {
|
||
|
|
return func(w http.ResponseWriter, req *http.Request) {
|
||
|
|
formatter := render.New(render.Options{IndentJSON: true})
|
||
|
|
formatter.JSON(w, http.StatusOK, out_val)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//时间搓转换成日期
|
||
|
|
/*
|
||
|
|
@timestamp 待转换的时间戳
|
||
|
|
*/
|
||
|
|
func UnixTimeToDay(timestamp int64) string {
|
||
|
|
datetime := time.Unix(timestamp, 0).Format(timeLayout)
|
||
|
|
return datetime
|
||
|
|
}
|