Last active
January 2, 2021 04:38
-
-
Save ilmiawan/0dde54b68bcc0ed38e14b6fec1770307 to your computer and use it in GitHub Desktop.
contoh fungsi umum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GetCache to get data from cache | |
func GetCache(key string, result interface{}) { | |
res, err := cache.Get(key) | |
if err != nil { | |
log.Errorf("[ERROR] failed fetching cache: %v", err) | |
return | |
} | |
err = json.Unmarshal(res, result) | |
if err != nil { | |
log.Errorf("[ERROR] failed parsing cache : %v", err) | |
return | |
} | |
return | |
} | |
// DateToStringFormat date checker | |
func DateToStringFormat(date time.Time, format string) string { | |
dateForm := time.RFC3339 | |
if len(format) > 0 { | |
dateForm = format | |
} | |
if date.IsZero() { | |
return "" | |
} | |
return date.Format(dateForm) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment