package mainimport"fmt"funcmain(){var courseMap =map[string]string{"go":"go1","grpc":"grpc1","gin":"gin1",}//var courseMap1=make(map[string]string,3)courseMap["sql"]="mysql"fmt.Println(courseMap["sql"])for key, value :=range courseMap {fmt.Println(key, value)}d, ok := courseMap["java"]//若不存在,则值为""fmt.Println(d, ok)//"",falsedelete(courseMap,"gin")delete(courseMap,"cpp")//不存在也不会报错}
list
package mainimport("container/list""fmt")funcmain(){var myList list.ListmyList.PushBack("go")myList.PushBack("grpc")myList.PushBack("gin")fmt.Println(myList)//指针myList.PushFront("sql")myList.InsertBefore("last", myList.Back())for it := myList.Front(); it !=nil; it = it.Next(){fmt.Println(it.Value)}for it := myList.Back(); it !=nil; it = it.Prev(){fmt.Println(it.Value)}}