package main

import (
"fmt"
"reflect"
)

func main() {

// make函数
//makeSlice() // 创建切片
//makeMap() // 创建集合
//makeChan() // 创建channel
NewMap() // make创建的是指针类型 new的是引用类型
}

func NewMap() {
mp := new(map[int] string)
mp1 := make(map[int] string)
fmt.Println(reflect.TypeOf(mp))
fmt.Println(reflect.TypeOf(mp1))
}


func makeSlice(){
sl := make([]string,3)
sl[0] = "a";
sl[1] = "b";
sl[2] = "c";
fmt.Println(sl)

}

func makeMap(){
mp := make(map[int] string)

mp[0] = "hello"
mp[1] = "world"
mp[33] = "!"
fmt.Println(mp)
}

func makeChan() {
mchan := make(chan string)

go func() {
mchan <- "hello world"
}()

message := <- mchan

fmt.Println(message)
}