838c6f90b7
* initial commit for setting shared board configuration * add unit test * working again * update default config * initial commit for setting shared board configuration * add unit test * working again * update default config * add unit tests, some clean up * more cleanup * more clean up * remove header text for GH-1105 * remove unnecessary logs * update text * fix lint errors * more lint fixes * webapp lint fixes * Update mattermost-plugin/plugin.json Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com> * Update mattermost-plugin/plugin.json Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com> * update for review, sync with main Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>
32 lines
603 B
Go
32 lines
603 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
// CreateGUID returns a random GUID.
|
|
func CreateGUID() string {
|
|
b := make([]byte, 16)
|
|
_, err := rand.Read(b)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
uuid := fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
|
|
|
|
return uuid
|
|
}
|
|
|
|
// GetMillis is a convenience method to get milliseconds since epoch.
|
|
func GetMillis() int64 {
|
|
return time.Now().UnixNano() / int64(time.Millisecond)
|
|
}
|
|
|
|
func StructToMap(v interface{}) (m map[string]interface{}) {
|
|
b, _ := json.Marshal(v)
|
|
_ = json.Unmarshal(b, &m)
|
|
return
|
|
}
|