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

Conversation

SilverRainZ
Copy link
Contributor

@SilverRainZ SilverRainZ commented May 30, 2022

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 SilverRainZ force-pushed the fix-go-printer-sandbox-example branch from 18baac2 to 721e999 Compare May 30, 2022 06:14
@gopherbot
Copy link
Contributor

This PR (HEAD: 721e999) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/409314 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Daniel Martí:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 张盛宇:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Daniel Martí:

Patch Set 1:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 张盛宇:

Patch Set 1:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@SilverRainZ SilverRainZ force-pushed the fix-go-printer-sandbox-example branch from 721e999 to 6d0a580 Compare August 22, 2022 10:29
@gopherbot
Copy link
Contributor

This PR (HEAD: 6d0a580) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/409314 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from 张盛宇:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Daniel Martí:

Patch Set 2: Code-Review+2

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

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 SilverRainZ force-pushed the fix-go-printer-sandbox-example branch from 6d0a580 to bac1189 Compare August 22, 2022 11:48
@gopherbot
Copy link
Contributor

This PR (HEAD: bac1189) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/409314 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from 张盛宇:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@SilverRainZ SilverRainZ changed the title go/printer: don't print example entry function directly go/printer: make ExampleFprint correctly run as online example Aug 23, 2022
@gopherbot
Copy link
Contributor

Message from Bryan Mills:

Patch Set 4: Code-Review+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Daniel Martí:

Patch Set 4: Run-TryBot+1 Code-Review+2


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Heschi Kreinick:

Patch Set 4: Code-Review+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 4: TryBot-Result+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/409314.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Sep 16, 2022
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.

Change-Id: Ia2b772937081b58a0fce9860838959c95f2d650c
GitHub-Last-Rev: bac1189
GitHub-Pull-Request: #53141
Reviewed-on: https://go-review.googlesource.com/c/go/+/409314
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Daniel Martí <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/409314 has been merged.

@gopherbot gopherbot closed this Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants