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

Go 1.11's path.Dir() doesn't work on Windows #28167

Closed
hsluoyz opened this issue Oct 12, 2018 · 3 comments
Closed

Go 1.11's path.Dir() doesn't work on Windows #28167

hsluoyz opened this issue Oct 12, 2018 · 3 comments

Comments

@hsluoyz
Copy link

hsluoyz commented Oct 12, 2018

What version of Go are you using (go version)?

go version go1.11 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Latest Win10 x64

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxx\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\GoPath
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\xxx\AppData\Local\Temp\go-build797940962=/tmp/go-build -gno-record-gcc-switches

What did you do?

println(path.Dir("C:\\111\\2.txt"))

What did you expect to see?

C:\\111

What did you see instead?

.
@mattn
Copy link
Member

mattn commented Oct 12, 2018

use path/filepath instead of path. path package is not for physical paths.

@kardianos
Copy link
Contributor

@mattn is correct. Use filepath

@hsluoyz
Copy link
Author

hsluoyz commented Oct 12, 2018

Thanks for this perfect solution!

@golang golang locked and limited conversation to collaborators Oct 12, 2019
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

4 participants