Initial
This commit is contained in:
27
app/lib/helpers/util.go
Normal file
27
app/lib/helpers/util.go
Normal file
@ -0,0 +1,27 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
func UTCNow() time.Time {
|
||||
utc, _ := time.LoadLocation("UTC")
|
||||
return time.Now().In(utc)
|
||||
}
|
||||
|
||||
// UNUSED allows unused variables to be included in Go programs
|
||||
func UNUSED(x ...interface{}) {}
|
||||
|
||||
func StructToMap(data interface{}) (map[string]interface{}, error) {
|
||||
dataBytes, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mapData := make(map[string]interface{})
|
||||
err = json.Unmarshal(dataBytes, &mapData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mapData, nil
|
||||
}
|
||||
Reference in New Issue
Block a user