Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed: embed.FS does not retain modTime #45445

Closed
MovieStoreGuy opened this issue Apr 8, 2021 · 1 comment
Closed

embed: embed.FS does not retain modTime #45445

MovieStoreGuy opened this issue Apr 8, 2021 · 1 comment

Comments

@MovieStoreGuy
Copy link

MovieStoreGuy commented Apr 8, 2021

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()

@seankhliao
Copy link
Member

Duplicate of #44854

@seankhliao seankhliao marked this as a duplicate of #44854 Apr 8, 2021
@golang golang locked and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants