diff --git a/cachemap/cache.tmpl b/cachemap/cache.tmpl index b77273e..1e10eaa 100644 --- a/cachemap/cache.tmpl +++ b/cachemap/cache.tmpl @@ -129,7 +129,7 @@ func (c *cache) Get(k string) ({{.ValueType}}, bool) { // TODO: inline time.Now implementation if !found || item.Expiration > 0 && time.Now().UnixNano() > item.Expiration { c.mu.RUnlock() - return {{.ValueType}}(0), false + return {{.ZeroValue}}, false } c.mu.RUnlock() return item.Object, true @@ -207,8 +207,7 @@ func (c *cache) delete(k string) ({{.ValueType}}, bool) { delete(c.items, k) return v.Object, true } - //TODO: zeroValue - return 0, false + return {{.ZeroValue}}, false } func (c *cache) deleteFast(k string) { diff --git a/cachemap/main.go b/cachemap/main.go index fc63fd7..deab2ba 100644 --- a/cachemap/main.go +++ b/cachemap/main.go @@ -147,7 +147,6 @@ FIND: if typeName == "" { typeName = *valueType } - fmt.Println("real", typeName, "value", *valueType) zeroTypeValue := zeroValue(typeName) f, err := os.OpenFile(fmt.Sprintf("%s2%s_cachemap.go", *keyType, *valueType), os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0644) if err != nil {