-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Go version
go1.25.3 X:nodwarf5 linux/amd64
Output of go env in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/taqiyeddine/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/taqiyeddine/.config/go/env'
GOEXE=''
GOEXPERIMENT='nodwarf5'
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3604398138=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/taqiyeddine/daar-project3/go.mod'
GOMODCACHE='/home/taqiyeddine/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/taqiyeddine/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/taqiyeddine/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.3 X:nodwarf5'
GOWORK=''
PKG_CONFIG='pkg-config'What did you do?
I was reading the documentation for strings.TrimSpace in the standard library:
TrimSpace returns a slice of the string s, with all leading and trailing white space removed, as defined by Unicode.
As a learner, the phrase “returns a slice of the string s” was confusing, because the function returns a string, not a Go slice ([]T). In Go documentation, “slice” almost always refers to the slice type, so this wording feels ambiguous.
What did you see happen?
The documentation suggests that TrimSpace returns “a slice of the string s”, which can be interpreted as returning a slice type, not a string. The wording is technically about the underlying storage, but it reads as misleading.
What did you expect to see?
A clearer description that avoids the ambiguous use of the word “slice”. For example:
TrimSpace returns a substring of s with all leading and trailing white space removed, as defined by Unicode.
This wording avoids confusion between “slice” the data type ([]T) and “slice” the informal concept of a substring.