package main
import "fmt"
func main() {
ch2 := make(chan string, 1)
go func() {
ch2 <- ("已到达!")
}()
var value string = "数据"
// val := <- ch2
// value = value + val
value=value+(<-ch2)
fmt.Println(value)
}
import "fmt"
func main() {
ch2 := make(chan string, 1)
go func() {
ch2 <- ("已到达!")
}()
var value string = "数据"
// val := <- ch2
// value = value + val
value=value+(<-ch2)
fmt.Println(value)
}
2021-11-23
最新回答 / 慕慕8460195
既然是跨平台的语言那就是说主流测操作系统都支持 不过win应该是安装最为简单的了 win的安装文件会完成基本软件会使用到的各种配置(包括但不限于环境变量,注册表等)
2021-01-31
只加这一行貌似更简单
defer func(reverse_fi int){
fmt.Printf("%d ", reverse_fi)
}(fibonacci(i))
defer func(reverse_fi int){
fmt.Printf("%d ", reverse_fi)
}(fibonacci(i))
2021-01-21
func main() {
go func() {
fmt.Println("1")
}()
go func() {
time.Sleep(100 * time.Millisecond)
fmt.Println("2")
}()
go func() {
time.Sleep(200 * time.Millisecond)
fmt.Println("3")
}()
time.Sleep(500 * time.Millisecond)
}
go func() {
fmt.Println("1")
}()
go func() {
time.Sleep(100 * time.Millisecond)
fmt.Println("2")
}()
go func() {
time.Sleep(200 * time.Millisecond)
fmt.Println("3")
}()
time.Sleep(500 * time.Millisecond)
}
2021-01-14
func main() {
defer func() {
if p := recover(); p != nil {
fmt.Printf("Fatal error: %s\n", p)
}
}()
fmt.Println("Enter main")
outerFunc()
fmt.Println("Quit main")
}
defer func() {
if p := recover(); p != nil {
fmt.Printf("Fatal error: %s\n", p)
}
}()
fmt.Println("Enter main")
outerFunc()
fmt.Println("Quit main")
}
2021-01-14
func main() {
map1 := map[int]string{1: "Golang", 2: "Java", 3: "Python", 4: "C"}
sorted := [4]string{map1[1],map1[2],map1[3],map1[4]}
for i,v :=range sorted{
fmt.Printf("%d: %s\n",i+1,v)
}
}
map1 := map[int]string{1: "Golang", 2: "Java", 3: "Python", 4: "C"}
sorted := [4]string{map1[1],map1[2],map1[3],map1[4]}
for i,v :=range sorted{
fmt.Printf("%d: %s\n",i+1,v)
}
}
2021-01-14
func main() {
ia := []interface{}{byte(6), 'a', uint(10), int32(-4)}
switch v := ia[rand.Intn(4) ]; interface{}(v).(type) {
case interface{} :
fmt.Printf("Case A.")
case byte :
fmt.Printf("Case B.")
default:
fmt.Println("Unknown!")
}
}
ia := []interface{}{byte(6), 'a', uint(10), int32(-4)}
switch v := ia[rand.Intn(4) ]; interface{}(v).(type) {
case interface{} :
fmt.Printf("Case A.")
case byte :
fmt.Printf("Case B.")
default:
fmt.Println("Unknown!")
}
}
2021-01-14
type Dog struct {
Name_ string
Age_ uint8
}
func (d Dog)Name() string{
return d.Name_
}
func (d Dog)Age() uint8{
return d.Age_
}
Name_ string
Age_ uint8
}
func (d Dog)Name() string{
return d.Name_
}
func (d Dog)Age() uint8{
return d.Age_
}
2021-01-12