package main import "fmt" type Point struct{x, y int} func (p Point) swap(){ p.x, p.y = p.y, p.x } func main () { s:=Point{1, 2} s.swap() fmt.Println(s.x, s.y) //JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 fmt.Println("Hello world! - go.jsrun.net ") }