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

path/filepath: join function does not allow UNC for pipe #23467

Closed
kayila opened this issue Jan 17, 2018 · 3 comments
Closed

path/filepath: join function does not allow UNC for pipe #23467

kayila opened this issue Jan 17, 2018 · 3 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@kayila
Copy link

kayila commented Jan 17, 2018

The path has to start with \\.\pipe\ for named pipes on Windows, but filepath.Join() removes the leading \\..

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

1.9.1

Does this issue reproduce with the latest release?

Yes. (1.9.2, as of opening this issue.)

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

GOARCH="amd64"
GOBIN=""
GOEXE=".exe"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="windows"
GOPATH="/home/kayila/go"
GORACE=""
GOROOT="/usr/lib/go-1.7"
GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build187455838=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="0"

What did you do?

package main

import (
	"fmt"
	"path/filepath"
)

func main() {
	fmt.Println(filepath.Join("\\\\.", "pipe", "blah"))
	fmt.Println(filepath.Join("\\\\.\\pipe", "blah"))
}

What did you expect to see?

\\.\pipe\blah
\\.\pipe\blah

What did you see instead?

\pipe\blah
\pipe\blah
@cznic
Copy link
Contributor

cznic commented Jan 18, 2018

If you know, that a named pipe on Windows has a special prefix that intentionally does comply with filepath.Clean rules, just use

`\\.\` + filepath.Join("pipe", "blah")

ie. don't pass the special prefix to filepath.Join that's documented to Clean the result.

@alexbrainman
Copy link
Member

@kayila yes path/filepath package does not support pipe names. But it also does not support paths starting with \\?\ either (which are more common).

https://golang.org/doc/contribute.html if you decide to add missing functionality.

Alex

@ianlancetaylor ianlancetaylor added OS-Windows NeedsFix The path to resolution is known, but the work has not been done. labels Mar 28, 2018
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Mar 28, 2018
@qmuntal
Copy link
Contributor

qmuntal commented May 16, 2023

Can't reproduce in go1.20. Probably fixed by CL 444280.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

5 participants