我想追加的值的映射图的内部阵列:追加值,以阵列
var MyMap map[string]Example
type Example struct {
Id []int
Name []string
}
这里是我尝试,但我不能指向实施例的一个目的,以追加到阵列。
package main
import (
"fmt"
)
type Example struct {
Id []int
Name []string
}
func (data *Example) AppendExample(id int,name string) {
data.Id = append(data.Id, id)
data.Name = append(data.Name, name)
}
var MyMap map[string]Example
func main() {
MyMap = make(map[string]Example)
MyMap["key1"] = Oferty.AppendExample(1,"SomeText")
fmt.Println(MyMap)
}
我以为我解决了这个问题,但我没有解决它,因为我需要分配循环中的键匹配值。 – Saem