Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8978737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:41:05+00:00 2026-06-15T19:41:05+00:00

There are some nice executable examples in the Go standard library. How can I

  • 0

There are some nice executable examples in the Go standard library. How can I add such an example to my own API documentation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:41:06+00:00Added an answer on June 15, 2026 at 7:41 pm

    Output of $ go help testfunc:

    The ‘go test’ command expects to find test, benchmark, and example functions
    in the “*_test.go” files corresponding to the package under test.

    A test function is one named TestXXX (where XXX is any alphanumeric string
    not starting with a lower case letter) and should have the signature,

     func TestXXX(t *testing.T) { ... }
    

    A benchmark function is one named BenchmarkXXX and should have the signature,

     func BenchmarkXXX(b *testing.B) { ... }
    

    An example function is similar to a test function but, instead of using *testing.T
    to report success or failure, prints output to os.Stdout and os.Stderr.
    That output is compared against the function’s “Output:” comment, which
    must be the last comment in the function body (see example below). An
    example with no such comment, or with no text after “Output:” is compiled
    but not executed.

    Godoc displays the body of ExampleXXX to demonstrate the use
    of the function, constant, or variable XXX. An example of a method M with
    receiver type T or *T is named ExampleT_M. There may be multiple examples
    for a given function, constant, or variable, distinguished by a trailing _xxx,
    where xxx is a suffix not beginning with an upper case letter.

    Here is an example of an example:

    func ExamplePrintln() {
            Println("The output of\nthis example.")
            // Output: The output of
            // this example.
    }
    

    The entire test file is presented as the example when it contains a single
    example function, at least one other function, type, variable, or constant
    declaration, and no test or benchmark functions.

    See the documentation of the testing package for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some nice documentation for Windows batch scripting I can download and refer
Is there some regex that can be passed to re-seq such that it will
I know there are some nice new features in C# 4.0 but I can't,
I got some binary files containing integers. Is there some nice Unix command, that
After messing about with F# there are some really nice features that I think
In Spring Source Toolsuite (Eclipse with some Spring tuning) there is nice wizard to
Is there some kind of software that I can feed uploaded images to and
Is there some event I can use to tell when the SelectedIndices property changes
There are some nice libraries for testing in Scala ( Specs , ScalaTest ,
My iPhone app generates some very nice-looking plist files. I can look at them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.