This commit is contained in:
Eden Kirin
2024-06-18 22:01:31 +02:00
commit 21dcabe180
21 changed files with 1039 additions and 0 deletions

27
app/lib/helpers/util.go Normal file
View 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
}