标签:har cond package second 类型 time 基本 import main
====type==== import ( "fmt" ) func main() { type bigint byte //定义类型 var a bigint fmt.Printf("a type is %T\n",a) type( long int64 char byte ) var b char =‘a‘ var c long =1000 fmt.Printf("b=%c,c=%d",b,c) ========channel========
package main import ( "time" "fmt" ) func test_channel() { //ch:=make(chan int) ch<-1 ch<-1 fmt.Println("come to end go runtime 1") } var ch chan int func main() { ch =make(chan int,0) go test_channel() time.Sleep(2* time.Second) fmt.Println("runing end") <-ch time.Sleep(time.Second) } =====协程========== package main import ( "fmt" "time" ) func test_Rou(){ fmt.Println("ddd") } func Add (x,y int){ z:=x+y fmt.Println(z) } func main() { go test_Rou() for index := 0; index < 10; index++ { go Add(index,index) } time.Sleep(10) }
标签:har cond package second 类型 time 基本 import main
原文地址:https://www.cnblogs.com/dqh123/p/12069318.html