when running go doc -ex io, it’ll show me the names of the example functions, but when using the -all flag to show additional information, it displays nothing about the example functions
$ go version
go version go1.27.1 linux/amd64
$ go doc -ex io | rg Example
func ExampleCopy()
func ExampleCopyBuffer()
func ExampleCopyN()
func ExamplePipe()
func ExampleReadAll()
func ExampleReadAtLeast()
func ExampleReadFull()
func ExampleWriteString()
func ExampleLimitReader()
func ExampleMultiReader()
func ExampleTeeReader()
func ExampleSectionReader()
func ExampleMultiWriter()
$ go doc -ex -all io | rg Example
The pipe in the example is hiding the part you want to inspect. rg Example only prints lines that contain the word Example, so it will show the function names and discard the bodies and surrounding documentation. Try go doc -all -ex io without the pipe first, or target one example such as go doc -ex io.ExampleCopy. If you still want filtering, use context with ripgrep (for example rg -A 8 '^func Example') or save the full output and inspect it. The -all flag controls how much package documentation go doc emits; it does not change what a later grep keeps.
This answers my question: yes -ex flag came with release 1.27.
Quote :
The go doc command now accepts the -ex command-line option to list executable examples of the given package or symbol. When an example name is passed on the command line (such as go doc bytes.ExampleBuffer), go doc now prints the example source code along with comments.
go doc -ex io.ExampleCopy does work, but go doc -all -ex io does not output any information about examples at all, despite go doc -ex io correctly doing so. I manually checked the entire output, and grep is not hiding any information. I just used grep to make my post more succinct.
this is an issue for me as i use go doc -all <pkg> to learn about what functions exist in a package, if go -doc -all -ex <pkg> doesn’t contain information about the examples, ill never know to type in go doc -ex <function> for a specific function.