go - Using new and assigning variable at the same time -


wd := new(time.weekday) fmt.println(wd.string()) 

the above 2 lines return sunday (weekdays start 0)

is possible me assign value along new ? other method tried

var wd time.weekday wd = 3 

this 1 returns wednesday

time.weekday int can assign such (or use defined constants adam suggested). can ask why need use new in situation?

package main  import (     "fmt"     "time" )  func main() {     var wd time.weekday = 3     fmt.println(wd) } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -