package main import ( "fmt" "image/color" ) type Point struct { X,Y float64 } type ColorRedPoint struct { Point Color color.RGBA } func main() { var cp ColorRedPoint cp.X = 1 // 第一種寫法 fmt.Println(cp.Point.X) // 第二種寫法 fmt.Println(cp.X) red := color.RGBA{255,0,0,255} blue := color.RGBA{0,0,255,255} var p = ColorRedPoint{Point{1,1},red} var p1 = ColorRedPoint{Point{2,2},blue} fmt.Println(p) fmt.Println(p1) }