github.com/q45/go@v0.0.0-20151101211701-a4fb8c13db3f/src/cmd/doc/testdata/pkg.go (about)

     1  // Copyright 2015 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package comment.
     6  package pkg
     7  
     8  // Constants
     9  
    10  // Comment about exported constant.
    11  const ExportedConstant = 1
    12  
    13  // Comment about internal constant.
    14  const internalConstant = 2
    15  
    16  // Comment about block of constants.
    17  const (
    18  	// Comment before ConstOne.
    19  	ConstOne   = 1
    20  	ConstTwo   = 2 // Comment on line with ConstTwo.
    21  	constThree = 3 // Comment on line with constThree.
    22  )
    23  
    24  // Const block where first entry is unexported.
    25  const (
    26  	constFour = iota
    27  	ConstFive
    28  	ConstSix
    29  )
    30  
    31  // Variables
    32  
    33  // Comment about exported variable.
    34  var ExportedVariable = 1
    35  
    36  // Comment about internal variable.
    37  var internalVariable = 2
    38  
    39  // Comment about block of variables.
    40  var (
    41  	// Comment before VarOne.
    42  	VarOne   = 1
    43  	VarTwo   = 2 // Comment on line with VarTwo.
    44  	varThree = 3 // Comment on line with varThree.
    45  )
    46  
    47  // Var block where first entry is unexported.
    48  var (
    49  	varFour = 4
    50  	VarFive = 5
    51  	varSix  = 6
    52  )
    53  
    54  // Comment about exported function.
    55  func ExportedFunc(a int) bool
    56  
    57  // Comment about internal function.
    58  func internalFunc(a int) bool
    59  
    60  // Comment about exported type.
    61  type ExportedType struct {
    62  	// Comment before exported field.
    63  	ExportedField   int
    64  	unexportedField int // Comment on line with unexported field.
    65  }
    66  
    67  // Comment about exported method.
    68  func (ExportedType) ExportedMethod(a int) bool {
    69  	return true
    70  }
    71  
    72  // Comment about unexported method.
    73  func (ExportedType) unexportedMethod(a int) bool {
    74  	return true
    75  }
    76  
    77  // Constants tied to ExportedType. (The type is a struct so this isn't valid Go,
    78  // but it parses and that's all we need.)
    79  const (
    80  	ExportedTypedConstant ExportedType = iota
    81  )
    82  
    83  // Comment about constructor for exported type.
    84  func ExportedTypeConstructor() *ExportedType {
    85  	return nil
    86  }
    87  
    88  const unexportedTypedConstant ExportedType = 1 // In a separate section to test -u.
    89  
    90  // Comment about unexported type.
    91  type unexportedType int
    92  
    93  func (unexportedType) ExportedMethod() bool {
    94  	return true
    95  }
    96  
    97  func (unexportedType) unexportedMethod() bool {
    98  	return true
    99  }
   100  
   101  // Constants tied to unexportedType.
   102  const (
   103  	ExportedTypedConstant_unexported unexportedType = iota
   104  )
   105  
   106  const unexportedTypedConstant unexportedType = 1 // In a separate section to test -u.
   107  
   108  // For case matching.
   109  const CaseMatch = 1
   110  const Casematch = 2