mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-20 16:45:56 +08:00
16 lines
276 B
Go
16 lines
276 B
Go
package main
|
|
|
|
type cache struct {
|
|
m map[string]int
|
|
}
|
|
|
|
func (c *cache) get1(bytes []byte) (v int, contains bool) {
|
|
key := string(bytes)
|
|
v, contains = c.m[key]
|
|
return
|
|
}
|
|
|
|
func (c *cache) get2(bytes []byte) (v int, contains bool) {
|
|
v, contains = c.m[string(bytes)]
|
|
return
|
|
}
|