~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/go/doc/example.go

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
// Examples returns the examples found in the files, sorted by Name field.
34
34
// The Order fields record the order in which the examples were encountered.
 
35
//
 
36
// Playable Examples must be in a package whose name ends in "_test".
 
37
// An Example is "playable" (the Play field is non-nil) in either of these
 
38
// circumstances:
 
39
//   - The example function is self-contained: the function references only
 
40
//     identifiers from other packages (or predeclared identifiers, such as
 
41
//     "int") and the test file does not include a dot import.
 
42
//   - The entire test file is the example: the file contains exactly one
 
43
//     example function, zero test or benchmark functions, and at least one
 
44
//     top-level function, type, variable, or constant declaration other
 
45
//     than the example function.
35
46
func Examples(files ...*ast.File) []*Example {
36
47
        var list []*Example
37
48
        for _, file := range files {
244
255
                }
245
256
        }
246
257
 
247
 
        // Strip "Output:" commment and adjust body end position.
 
258
        // Strip "Output:" comment and adjust body end position.
248
259
        body, comments = stripOutputComment(body, comments)
249
260
 
250
261
        // Synthesize import declaration.
307
318
        return &f
308
319
}
309
320
 
310
 
// stripOutputComment finds and removes an "Output:" commment from body
 
321
// stripOutputComment finds and removes an "Output:" comment from body
311
322
// and comments, and adjusts the body block's end position.
312
323
func stripOutputComment(body *ast.BlockStmt, comments []*ast.CommentGroup) (*ast.BlockStmt, []*ast.CommentGroup) {
313
324
        // Do nothing if no "Output:" comment found.