Skip to content

Commit

Permalink
Fix testable example: ExampleObjectPool
Browse files Browse the repository at this point in the history
Output is only checked when it is the last comment block in the testable example. See this golang issue for more info: golang/go#48362
  • Loading branch information
ameowlia committed Sep 21, 2021
1 parent 9fea52c commit d5ee7cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/x/pool/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ func ExampleObjectPool() {
o := p.Get().(*exampleObject)

fmt.Printf("Retrieved struct should have default values: %+v", o)
// Output: Retrieved struct should have default values: &{a:0 b:0 c:0}

// Use the exampleObject.
_ = o

// Reset the exampleObject and return it to the pool.
o.reset()
p.Put(o)

// Output: Retrieved struct should have default values: &{a:0 b:0 c:0}
}

0 comments on commit d5ee7cb

Please sign in to comment.