-
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.5 linux/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/root/.go/pkg/mod" GONOPROXY="gitlab.papegames.com,gitee.com" GONOSUMDB="gitlab.papegames.com,gitee.com" GOOS="linux" GOPATH="/root/.go:/root/go" GOPRIVATE="" GOPROXY="https://goproxy.cn,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.16.5" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/root/go/src/test/testdir/go.mod" 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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2652719403=/tmp/go-build -gno-record-gcc-switches"
What did you do?
package main
import (
"embed"
"fmt"
"os"
)
//go:embed test
var staticFS embed.FS
func main() {
fmt.Println(os.Open("./test"))
fmt.Println("----")
fmt.Println(os.Open("./test/"))
fmt.Println("----")
fmt.Println(staticFS.Open("test"))
fmt.Println("----")
fmt.Println(staticFS.Open("test/"))
}What did you expect to see?
the same as fmt.Println(staticFS.Open("test"))
What did you see instead?
&{0xc00004e180} <nil>
----
&{0xc00004e1e0} <nil>
----
&{0x4eab98 [{test/a str1
[63 163 252 108 86 4 30 104 91 211 217 230 175 19 117 126]} {test/b str2
[157 163 134 109 137 33 72 250 70 235 54 167 230 171 44 117]}] 0} <nil>
----
<nil> open test/: file does not exist
It cause http.FS can not found index.html, because dir always end with /