From 05cdbdb6c10f82f9dd52509500963910c37be045 Mon Sep 17 00:00:00 2001 From: Michael Dresner Date: Thu, 24 Mar 2022 23:47:55 +0300 Subject: [PATCH] Delete irrelevant examples --- README.md | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/README.md b/README.md index c5789cc..481e457 100644 --- a/README.md +++ b/README.md @@ -45,34 +45,10 @@ func main() { fmt.Println(foo) } - // Since Go is statically typed, and cache values can be anything, type - // assertion is needed when values are being passed to functions that don't - // take arbitrary types, (i.e. interface{}). The simplest way to do this for - // values which will only be used once--e.g. for passing to another - // function--is: - foo, found := c.Get("foo") - if found { - MyFunction(foo.(string)) - } - - // This gets tedious if the value is used several times in the same function. - // You might do either of the following instead: - if x, found := c.Get("foo"); found { - foo := x.(string) - // ... - } - // or - var foo string - if x, found := c.Get("foo"); found { - foo = x.(string) - } - // ... - // foo can then be passed around freely as a string - // Want performance? Store pointers! c.Set("foo", &MyStruct, cache.DefaultExpiration) if x, found := c.Get("foo"); found { - foo := x.(*MyStruct) + foo := x // ... } }