wd := new(time.Weekday)
fmt.Println(wd.String())
The above two lines return Sunday (weekdays start with a 0)
Is it possible for me to assign a value along with new ? Other method i tried is
var wd time.Weekday
wd = 3
this one returns Wednesday
time.Weekday is an int so you can assign it as such (or use the defined constants as Adam suggested). Can I ask why you need to use new in this situation?
package main
import (
"fmt"
"time"
)
func main() {
var wd time.Weekday = 3
fmt.Println(wd)
}
you can simply use the time.weekday constants for that:
wd := time.Wednesday