Sunday, September 20, 2026
HomeGolangHow do i exploit go doc -ex from 1.27? - Getting Assist

How do i exploit go doc -ex from 1.27? – Getting Assist


when operating go doc -ex io, it’ll present me the names of the instance features, however when utilizing the -all flag to point out extra info, it shows nothing in regards to the instance features

$ go model
go model go1.27.1 linux/amd64
$ go doc -ex io | rg Instance
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 Instance

The pipe within the instance is hiding the half you need to examine. rg Instance solely prints traces that include the phrase Instance, so it would present the perform names and discard the our bodies and surrounding documentation. Strive go doc -all -ex io with out the pipe first, or goal one instance reminiscent of go doc -ex io.ExampleCopy. In the event you nonetheless need filtering, use context with ripgrep (for instance rg -A 8 '^func Instance') or save the complete output and examine it. The -all flag controls how a lot bundle documentation go doc emits; it doesn’t change what a later grep retains.

Is -ex flag a function in go 27.x ?

This solutions my query: sure -ex flag got here with launch 1.27.

Quote :

The go doc command now accepts the -ex command-line choice to checklist executable examples of the given bundle or image. When an instance identify is handed on the command line (reminiscent of go doc bytes.ExampleBuffer), go doc now prints the instance supply code together with feedback.

go doc -ex io.ExampleCopy does work, however go doc -all -ex io doesn’t output any details about examples in any respect, regardless of go doc -ex io appropriately doing so. I manually checked the whole output, and grep shouldn’t be hiding any info. I simply used grep to make my put up extra succinct.

this is a matter for me as i exploit go doc -all <pkg> to find out about what features exist in a bundle, if go -doc -all -ex <pkg> doesn’t include details about the examples, ailing by no means know to kind in go doc -ex <perform> for a selected perform.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments