Skip to content

fmt: error in the documentation for fmt.Formatter? #60358

@myitcv

Description

@myitcv

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

$ go version
go version devel go1.21-40bdc56180 Tue May 23 13:22:25 2023 +0000 linux/arm64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/myitcv/gostuff/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/dev/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/dev/go/pkg/tool/linux_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
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 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build697360160=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ go doc fmt Formatter

What did you expect to see?

Documentation that is consistent with the intended use of fmt.Formatter

What did you see instead?

package fmt // import "fmt"

type Formatter interface {
        Format(f State, verb rune)
}
    Formatter is implemented by any value that has a Format method. The
    implementation controls how State and rune are interpreted, and may call
    Sprint(f) or Fprint(f) etc. to generate its output.

It's unclear to me how a call to Sprint(f) can possibly work with with a fmt.State value.

A call to Fprint(f) yes, but not Sprint(f).

Am I missing something obvious, or is this a mistake in the docs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions