-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.10 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mlindner/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mlindner/gocode"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bx/wsy1g9fd10959r8nq8fmrzw80000gp/T/go-build930815221=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
https://play.golang.org/p/QyoSve9DTpt
pass ParseInLocation a string that does not specify a location, and don't provide a location explicitly.
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
I expected it to see it default to UTC, as per documentation:
First, in the absence of time zone information, Parse interprets a time as UTC;
Since "loc" is a *Location, nil should be a valid location. I understand that it may be also be interpreted that there must be a location in the string and format, or in the location provided, but at least one must be provided. However, that is not stated nor implied by the documentation or the code.
What did you see instead?
panic: time: missing Location in call to Date
goroutine 1 [running]:
time.Date(0x7e2, 0x5, 0x1e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/usr/local/go/src/time/time.go:1313 +0x720
time.parse(0x11239f, 0xa, 0x10ff02, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/usr/local/go/src/time/format.go:1094 +0x2ca0
time.ParseInLocation(0x11239f, 0xa, 0x10ff02, 0xa, 0x0, 0x1a4780, 0x0, 0x0, 0x0, 0x0, ...)
/usr/local/go/src/time/format.go:783 +0xa0
main.main()
/tmp/sandbox728893309/main.go:13 +0x80
I believe the problem is in format.go, line 783, which reads:
return parse(layout, value, loc, loc)
and should (I believe) read:
if loc {
return parse(layout, value, loc, loc)
} else {
return parse(layout, value, UTC, loc)
}