C/C++とgolangのキャストの違い

C/C++ Golang
a_int = int(a) a_int = a.(int)
struct PERSON{
int person_number;
int age;
}(PERSON)p
type PERSON struct{
person_number int
age int
}p.(PERSON)
type locInfo struct{
   lon float64
   lat float64
}
var ch1 chan interface{}
var li LocInfo
func main(){
    ch = make(chan interface{}) // チャネルの初期化
    li.lon = 12
    li.lat = 15
    ch <- li
}
func sub(){
  li1 :=<-ch
   li2 := li1.(locInfo)
   a := li2.lon
   b := li2.lat
}

 

 

未分類

Posted by ebata