Skip to content
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

x/website: #38323

Closed
Gituser143 opened this issue Apr 9, 2020 · 2 comments
Closed

x/website: #38323

Gituser143 opened this issue Apr 9, 2020 · 2 comments

Comments

@Gituser143
Copy link

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

go version go1.13.8 linux/amd64

Does this issue reproduce with the latest release?

The issue is with documentation of functions in the strings package.

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

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.13/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build282555768=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Read the package strings documentation on https://golang.org/pkg/strings/

What did you expect to see?

Functions having arguments along with their types. A complete and accurate function definition.

What did you see instead?

19 functions have a first argument of type string, but do not show the type in the function declaration. These functions are:

  • func Contains(s, substr string) bool
  • func ContainsAny(s, chars string)
  • func Count(s, substr string) int
  • func EqualFold(s, t string) bool
  • func HasPrefix(s, prefix string) bool
  • func HasSuffix(s, suffix string) bool
  • func Index(s, substr string) int
  • func IndexAny(s, chars string) int
  • func LastIndex(s, substr string) int
  • func LastIndexAny(s, chars string) int
  • func Replace(s, old, new string, n int) string
  • func ReplaceAll(s, old, new string) string
  • func Split(s, sep string) []string
  • func SplitAfter(s, sep string) []string
  • func SplitAfterN(s, sep string, n int) []string
  • func SplitN(s, sep string, n int) []stringfunc ToValidUTF8(s, replacement string) string
  • func TrimPrefix(s, prefix string) string
  • func TrimSuffix(s, suffix string) string
@gopherbot gopherbot added this to the Unreleased milestone Apr 9, 2020
@ALTree
Copy link
Member

ALTree commented Apr 9, 2020

Hi @Gituser143,

this is how type declarations work in Go. When you write:

var a, b int

both a and b are of type int. C also works this way: int a, b; declares both a and b of type int.

In Go, function signatures behave in the same way. s, substr string means that both s and substr are of type string. See https://tour.golang.org/basics/5 (and the tour in general) for an introduction to the language.

Closing here, since this is working as intended.

@ALTree ALTree closed this as completed Apr 9, 2020
@Gituser143
Copy link
Author

Thank you at @ALTree for the clarification! I apologise for my confusion.

@golang golang locked and limited conversation to collaborators Apr 9, 2021
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

3 participants