-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed as not planned
Labels
Description
Go version
go version go1.21.7 darwin/arm64
Output of go env in your module/workspace:
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/senlin/Library/Caches/go-build'
GOENV='/Users/senlin/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/senlin/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/senlin/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go@1.21/1.21.7/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go@1.21/1.21.7/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.7'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/0y/13n782px5h37zxnxtrmtyc000000gn/T/go-build1437991706=/tmp/go-build -gno-record-gcc-switches -fno-common'What did you do?
rawUrl := "https://www.example.com?z=1"
addPath := "/a/b"
parsedUrl, _ := url.Parse(rawUrl)
parsedUrl = parsedUrl.JoinPath(addPath)
fmt.Println(parsedUrl.Path)
This outputs a/b. But if the rawUrl has a base path, eg. rawUrl := "https://www.example.com/api?z=1", output will be /api/a/b. This is an inconsistent treatment of leading "/".
What did you see happen?
All the time.
What did you expect to see?
Leading "/" present in all (*URL) .Path variables.