mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-21 00:47:11 +08:00
27 lines
439 B
Go
27 lines
439 B
Go
package concepts
|
|
|
|
type Store struct {
|
|
m map[string]*Foo
|
|
}
|
|
|
|
func (s Store) Put(id string, foo *Foo) {
|
|
s.m[id] = foo
|
|
// ...
|
|
}
|
|
|
|
type Foo struct{}
|
|
|
|
func updateMapValue(mapValue map[string]LargeStruct, id string) {
|
|
value := mapValue[id]
|
|
value.foo = "bar"
|
|
mapValue[id] = value
|
|
}
|
|
|
|
func updateMapPointer(mapPointer map[string]*LargeStruct, id string) {
|
|
mapPointer[id].foo = "bar"
|
|
}
|
|
|
|
type LargeStruct struct {
|
|
foo string
|
|
_ [1024]int64
|
|
}
|