Go version
go version go1.26.3 windows/amd64
What did you do?
On Windows, filepath.Rel never returns when the base path is a UNC volume root (\\host\share) and the target path is the same volume root with a trailing separator.
filepath.Clean does not normalize this away: it preserves the trailing separator on a volume root (the UNC share root is treated like C:\), so the two arguments stay different and Rel loops.
package main
import (
"fmt"
"path/filepath"
)
func main() {
// filepath.Clean(`\\host\share\`) == `\\host\share\` (trailing separator kept,
// as for any volume root), so Clean does not avoid the problem.
fmt.Println(filepath.Rel(`\\host\share`, filepath.Clean(`\\host\share\`)))
}
This is pure string manipulation, no filesystem access, so the share does not need to exist, and GOOS=windows is the only requirement.
What did you see instead?
The call never returns; the goroutine consumes a full CPU core indefinitely.
Go version
go version go1.26.3 windows/amd64
What did you do?
On Windows, filepath.Rel never returns when the base path is a UNC volume root (
\\host\share) and the target path is the same volume root with a trailing separator.filepath.Cleandoes not normalize this away: it preserves the trailing separator on a volume root (the UNC share root is treated likeC:\), so the two arguments stay different and Rel loops.This is pure string manipulation, no filesystem access, so the share does not need to exist, and GOOS=windows is the only requirement.
What did you see instead?
The call never returns; the goroutine consumes a full CPU core indefinitely.