Skip to content

Commit a17a6c8

Browse files
committed
maps typo
1 parent c81cca2 commit a17a6c8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

content/posts/2025-01-08-getOrMake.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ However, the values of those maps can be any Go type at all, including any other
3232

3333
```go
3434
// nested maps, two deep.
35-
var mapOfMaps map[string]maps[string]string
35+
var mapOfMaps map[string]map[string]string
3636
```
3737

3838
And the values for those *nested* maps, can also have maps.
3939

4040
```go
4141
// nested maps, two deep.
42-
var mapOfMapsOfMaps map[string]maps[string]map[string]string
42+
var mapOfMapsOfMaps map[string]map[string]map[string]string
4343
```
4444

4545
### Setting nested maps
@@ -54,11 +54,11 @@ value.
5454
```go
5555
func (w *mWrapper) Set(k1,k2,k3, value string) {
5656
if w.Map == nil {
57-
w.Map = make(map[string]maps[string]map[string]string)
57+
w.Map = make(map[string]map[string]map[string]string)
5858
}
5959
v1, ok := w.Map[k1]
6060
if !ok {
61-
v1 = make(map[string]maps[string]string)
61+
v1 = make(map[string]map[string]string)
6262
w.Map[k1] = v1
6363
}
6464
v2, ok := v1[k2]
@@ -86,7 +86,7 @@ Using generics, we can avoid some of this!
8686
```go
8787
func (w *mWrapper) Set(k1,k2,k3, value string) {
8888
if w.Map == nil {
89-
w.Map = make(map[string]maps[string]map[string]string)
89+
w.Map = make(map[string]map[string]map[string]string)
9090
}
9191
v1 := getOrMake(w.Map, k1)
9292
v2 := getOrMake(v1, k2)

0 commit comments

Comments
 (0)