package main
import "fmt"
type chaocai struct{
se string
wei string
next *chaocai
}
var head *chaocai
var tail *chaocai
func test(){
if head!=nil{
// fmt.Println(head)
test2:=new(chaocai)
test2.se="绿色的"
test2.wei="苦的"
tail.next=test2
}else{
fmt.Println("head is nil")
}
}
func main () {
//JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
// fmt.Println("Hello JSRUN! \n\n - from Golang .")
mapo:=new(chaocai)
mapo.se="红色"
mapo.wei="麻辣"
head=mapo
tail=mapo
// fmt.Println(head, tail)
test()
var tmp *chaocai
tmp=head
for tmp!=nil{
fmt.Println(tmp)
tmp=tmp.next
}
}
运行结果如下:
&{红色 麻辣 0xc420080180}
&{绿色的 苦的 }
运行结束,执行耗时:414毫秒