Skip to content

Instantly share code, notes, and snippets.

@ilmiawan
Last active January 2, 2021 04:38
Show Gist options
  • Save ilmiawan/0dde54b68bcc0ed38e14b6fec1770307 to your computer and use it in GitHub Desktop.
Save ilmiawan/0dde54b68bcc0ed38e14b6fec1770307 to your computer and use it in GitHub Desktop.
contoh fungsi umum
// 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