-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
What version of Go are you using (go version)?
$ go version go version go1.16.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes, currently testing against the latest for MacOS.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/smarciniak/Library/Caches/go-build" GOENV="/Users/smarciniak/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/smarciniak/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/smarciniak/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/Cellar/go/1.16.3/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.16.3/libexec/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.16.3" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6c/77rtd6551sj02zmxj_fv17200000gn/T/go-build4009098143=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Running the following code returns a ModTime of epoch when it should return a time of the file creation date.
This assumes that the file is saved as main.go
package main
import "embed"
//go:embed main.go
var content embed.FS
func main() {
f, err := content.Open("main.go")
if err != nil {
panic(err)
}
stat, err := f.Stat()
if err != nil {
panic(err)
}
if stat.ModTime().IsZero() {
panic("Does not retain the original f.Stat().ModTime()")
}
}What did you expect to see?
Running the above code should not panic since the time returned from the embed.FS structure should be non zero.
What did you see instead?
The following example will panic with:
Does not retain the original f.Stat().ModTime()