Skip to content

strings.TrimLeft("xxx "), In case of loss of a #62344

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
icowan opened this issue Aug 29, 2023 · 4 comments
Closed

strings.TrimLeft("xxx "), In case of loss of a #62344

icowan opened this issue Aug 29, 2023 · 4 comments

Comments

@icowan
Copy link

icowan commented Aug 29, 2023

        var authorization = "Bearer app-xxx"
	fmt.Println(strings.TrimLeft(authorization, "Bearer "))
	fmt.Println(strings.TrimLeft(authorization, "Bearer"))
	fmt.Println(strings.TrimSpace(strings.TrimLeft(authorization, "Bearer")))
	fmt.Println("-------")
	authorization = "Bearer sk-xxx"
	fmt.Println(strings.TrimLeft(authorization, "Bearer "))
	fmt.Println(strings.TrimLeft(authorization, "Bearer"))
	fmt.Println(strings.TrimSpace(strings.TrimLeft(authorization, "Bearer")))
image

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

go version go1.20.1 darwin/amd64

Does this issue reproduce with the latest release?

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

go env Output
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/dudulu/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/go"
GOPRIVATE=""
GOPROXY=""
GOROOT="/go/go1.20.1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/go/go1.20.1/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="0"
GOMOD="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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/qd/h_6jw84502g0r1q7b61w3wsc0000gn/T/go-build257210823=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

nothing

What did you expect to see?

// pp-

What did you see instead?

// app-

@gazerro
Copy link
Contributor

gazerro commented Aug 29, 2023

This is the correct behavior, use the TrimPrefix function instead.

@realpg
Copy link

realpg commented Aug 29, 2023

please read the manual before post an issue

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2023
@zigo101
Copy link

zigo101 commented Aug 29, 2023

https://github.com/golang/go/issues?q=is%3Aissue+TrimLeft+is%3Aclosed

@icowan
Copy link
Author

icowan commented Aug 30, 2023

This is the correct behavior, use the TrimPrefix function instead.

thank you!

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

6 participants