一些Go基础题库,初学者可以学习一下
package main
import (
"fmt"
)
func main() {
a := make([]int, 20)
a = []int{7, 8, 9, 10}
b := a[15:16]
fmt.Println(b)
}
输出:?
package main
import (
"fmt"
"sync"
)
func main() {
var m sync.Map
m.Store("address", map[string]string{"province": "江苏", "city": "南京"})
v, _ := m.Load("address")
fmt.Println(v["province"])
}
输出:?
点击查看答案
package main
import (
"fmt"
)
func hello(i *int) int {
defer func() {
*i = 19
}()
return *i
}
func main() {
i := 10
j := hello(&i)
fmt.Println(i, j)
}
输出:?
点击查看答案