Go version
version go1.16.15 windows/amd64
Output of go env
in your module/workspace:
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\langyao\AppData\Local\go-build
set GOENV=C:\Users\langyao\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\langyao\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\langyao\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\langyao\sdk\go1.16.15
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\langyao\sdk\go1.16.15\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.15
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\langyao\Desktop\Self\projects\NZ\robot-callback\go.mod
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\langyao\AppData\Local\Temp\go-build1439212609=/tmp/go-build -gno-record-gcc-switches
What did you do?
strings.TrimLeft("tmp_at_abc", "tmp_at_")
What did you see happen?
the result is "bc"
What did you expect to see?
the result should be "abc"
Comment From: gabyhelp
Similar Issues
- Is That a bug to strings.TrimRight() ? #18045
- strings: TrimLeft fails in certain cases #61919
- strings.TrimRight works not the same #24891
- Strange behaviour of strings.TrimLeft #18160
- Something wrong with strings.TrimLeft when string start with '/v' #35149
- strings.TrimRight unexpected output #41557
- strings: TrimRight() is not entirely right #46885
- strings.TrimLeft act wrong return when contains ':' #28523
- strings.TrimLeft("xxx "), In case of loss of a #62344
- strings.TrimRight() has bug when trim some strings #14657
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: thepudds
Note TrimLeft takes a cutset:
https://pkg.go.dev/strings#TrimLeft
TrimLeft returns a slice of the string s with all leading Unicode code points contained in cutset removed.
To remove a prefix, use TrimPrefix instead.