Last active
January 2, 2021 04:40
-
-
Save ilmiawan/f0d1b8d221bce21d3e238f088de83b99 to your computer and use it in GitHub Desktop.
contoh generic parameter
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
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 | |
} | |
func GetListNegaraFromCache() []Negara { | |
result := make([]Negara, 0) | |
GetCache("negara", &result) | |
return result | |
} | |
func GetListProvinsiFromCache() []Provinsi { | |
result := make([]Provinsi, 0) | |
GetCache("provinsi", &result) | |
return result | |
} | |
func GetListKotaFromCache() []Kota { | |
result := make([]Kota, 0) | |
GetCache("kota", &result) | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment