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

go/printer: make ExampleFprint correctly run as online example #53141

Closed

Commits on Aug 22, 2022

  1. go/printer: make ExampleFprint correctly run as online example

    function "ExampleFprint" will be rewritten to function "main"
    when displayed on the godoc pages, so the online example is failed to
    run:
    
        Output:
    
        panic: function not found
    
        goroutine 1 [running]:
        main.parseFunc({0x4f772e, 0xf}, {0x4f713f, 0xd})
                /tmp/sandbox1264544227/prog.go:23 +0x13b
        main.main()
                /tmp/sandbox1264544227/prog.go:30 +0x45
    
    See: https://pkg.go.dev/go/printer#example-Fprint
    
    Add printSelf function to prevent the function not found when running in godoc
    sandbox. Beside, deleting the dummy test function to make the example show
    the entire file, as we want to show the newly added printSelf function.
    SilverRainZ committed Aug 22, 2022
    Configuration menu
    Copy the full SHA
    bac1189 View commit details
    Browse the repository at this point in the history