Skip to content

import/path: fs.FileInfo and fs.DirEntry,they have same two method called isDir() ,maybe should return same result? #69251

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

Closed
notmaster-C opened this issue Sep 4, 2024 · 1 comment

Comments

@notmaster-C
Copy link

Go version

go version go1.22.5 darwin/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/Library/Caches/go-build'
GOENV='/Users/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/go/pkg/mod'
GONOPROXY='*.baidu.com*'
GONOSUMDB='*'
GOOS='darwin'
GOPATH='/Users/go'
GOPRIVATE='*.baidu.com'
GOPROXY='https://goproxy.baidu-int.com'
GOROOT='/usr/local/Cellar/go/1.22.5/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/Cellar/go/1.22.5/libexec/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/Documents/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/l6/flvkntr11p71b8nkvzzxg43c0000gn/T/go-build3356946425=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

There are two ways to determine whether an object is a file or a folder.And I got two different result.
The reason for this situation is that the existence of soft links causes the judgment to seem incorrect.

err := filepath.WalkDir(folderPath, func(path string, info os.DirEntry, err error) error {
if !info.isDir(){
fmt.Println(123)
}
fileInfo,err:=os.Stat(folderPath)
if fileInfo.isDir() {
fmt.Println(123)
}
}

What did you see happen?

print:
123
123

What did you expect to see?

only print one "123"

There are two ways to determine whether an object is a file or a folder.And I got two different result.
The reason for this situation is that the existence of soft links causes the judgment to seem incorrect.

two method called isDir() maybe should return same result?

d68f0b301d8d5f6f2628a37573dabd0e

1701401b9e4ab22673c74c3d4a921778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants