I want to have a struct like this:
type Person struct {
Name string
DateJoined time
}
But this struct will not compile, because there is no type time
, isn't it? Should I alternatively use a string
and insert the time / date information there?
time
isn't a type. time.Time
is. See the package docs for the types: http://golang.org/pkg/time/
import time
type Person struct {
Name string
DateJoined time.Time
}
you need to import time package and of course you use time.Time btw, it returned error when I defined my own type as below with similar reason to you. And, someone helped me to do cast (ex. mytime(time.Now()).
type mytime time.Time
You can make your own package and import always so that all your own type in your convenience