Lines Matching refs:key
24 key := NewOnceKey("key")
26 a := once.Once(key, func() interface{} { return "a" }).(string)
27 b := once.Once(key, func() interface{} { return "b" }).(string)
34 t.Errorf(`second call to Once with the same key should return "a": %q`, b)
40 key := NewOnceKey("key")
44 …go once.Once(key, func() interface{} { close(ch); time.Sleep(100 * time.Millisecond); return "foo"…
46 a := once.Once(key, func() interface{} { return "bar" }).(string)
55 key := NewOnceKey("key")
57 a := once.Once(key, func() interface{} { return "a" }).(string)
58 b := once.Get(key).(string)
65 t.Errorf(`Get with the same key should return "a": %q`, b)
71 key := NewOnceKey("key")
81 once.Get(key)
86 key := NewOnceKey("key")
90 …go once.Once(key, func() interface{} { close(ch); time.Sleep(100 * time.Millisecond); return "foo"…
92 a := once.Get(key).(string)
101 key := NewOnceKey("key")
103 a := once.OnceStringSlice(key, func() []string { return []string{"a"} })
104 b := once.OnceStringSlice(key, func() []string { return []string{"a"} })
111 t.Errorf(`second call to OnceStringSlice with the same key should return ["a"]: %q`, b)
117 key := NewOnceKey("key")
119 …a, b := once.Once2StringSlice(key, func() ([]string, []string) { return []string{"a"}, []string{"b…
120 …c, d := once.Once2StringSlice(key, func() ([]string, []string) { return []string{"c"}, []string{"d…
127 …t.Errorf(`second call to Once2StringSlice with the same key should return ["a"], ["b"]: %q, %q`, c…
149 type key struct {
150 key string
153 key1 := NewCustomOnceKey(key{"key"})
154 key2 := NewCustomOnceKey(key{"key"})
164 t.Errorf(`second call to Once with the NewCustomOnceKey from equal key should return "a": %q`, b)
182 key := NewOnceKey("key")
193 a = once.Once(key, func() interface{} {
209 b := once.Once(key, func() interface{} {