M
M
Master Ruby2021-06-09 12:25:29
go
Master Ruby, 2021-06-09 12:25:29

How to add slice to map?

message := map[string]string{
    "cmd":       "subscribe",
    "auth_key":  "dfb496cca67e13b",
    "needed_bk": []string {"live"}
  }

How can I add a slice?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Mamonov, 2021-06-09
@Dunaevlad

We need to change the map type to map[string]interface{}
Like this

message := map[string]interface{}{
    "cmd":       "subscribe",
    "auth_key":  "dfb496cca67e13b",
    "needed_bk": []string {"live"},
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question