rameshjanjyam (2) [Avatar] Offline
#1
code:
package main

import "fmt"
import "time"

type SpeedingTicket struct {
DocumentNumber int
Driver
IssuingOfficer string
Location string
PostedSpeed int
ActualSpeed int
DateTime time.Time
}

type Driver struct {
LicenseNumber string
DriverName string
Address string
City string
State string
PostalCode int
LicenseExpiration time.Time
}

func main() {

tix := SpeedingTicket{
84756,
&Driver{"G234-0598-01287",
"Speedy Gonzales",
"123 Any Street",
"Albuquerque",
"NM",
51234,
time.Date(2017, time.May, 30, 0, 0, 0, 0, time.UTC),
},
"Officer D. Duck",
"Intersection of HWY 54 and HWY 41",
55,
67,
time.Date(2013, time.May, 4, 12, 51, 0, 0, time.UTC),
}

fmt.Println(*tix.Driver)

}

when I execute that I see this message

./types.go:30: cannot use Driver literal (type *Driver) as type Driver in field value

only if I change the embedded type "Driver" in "SpeedingTicket" struct to *Driver it works