• Andrew Gerrand's avatar
    godoc: make example code more readable with new comment convention · 11e113db
    Andrew Gerrand authored
    go/doc: move Examples to go/ast
    cmd/go: use go/doc to read examples
    src/pkg: update examples to use new convention
    
    This is to make whole file examples more readable. When presented as a
    complete function, preceding an Example with its output is confusing.
    The new convention is to put the expected output in the final comment
    of the example, preceded by the string "output:" (case insensitive).
    
    An idiomatic example looks like this:
    
    // This example demonstrates Foo by doing bar and quux.
    func ExampleFoo() {
            // example body that does bar and quux
    
            // Output:
            // example output
    }
    
    R=rsc, gri
    CC=golang-dev
    https://golang.org/cl/5673053
    11e113db
Name
Last commit
Last update
..
testdata Loading commit data...
bench_test.go Loading commit data...
decode.go Loading commit data...
decode_test.go Loading commit data...
encode.go Loading commit data...
encode_test.go Loading commit data...
example_test.go Loading commit data...
indent.go Loading commit data...
scanner.go Loading commit data...
scanner_test.go Loading commit data...
stream.go Loading commit data...
stream_test.go Loading commit data...
tagkey_test.go Loading commit data...
tags.go Loading commit data...
tags_test.go Loading commit data...