github.com/huandu/go@v0.0.0-20151114150818-04e615e41150/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  // Variables
    25  
    26  // Comment about exported variable.
    27  var ExportedVariable = 1
    28  
    29  // Comment about internal variable.
    30  var internalVariable = 2
    31  
    32  // Comment about block of variables.
    33  var (
    34  	// Comment before VarOne.
    35  	VarOne   = 1
    36  	VarTwo   = 2 // Comment on line with VarTwo.
    37  	varThree = 3 // Comment on line with varThree.
    38  )
    39  
    40  // Comment about exported function.
    41  func ExportedFunc(a int) bool
    42  
    43  // Comment about internal function.
    44  func internalFunc(a int) bool
    45  
    46  // Comment about exported type.
    47  type ExportedType struct {
    48  	// Comment before exported field.
    49  	ExportedField   int
    50  	unexportedField int // Comment on line with unexported field.
    51  }
    52  
    53  // Comment about exported method.
    54  func (ExportedType) ExportedMethod(a int) bool {
    55  	return true
    56  }
    57  
    58  // Comment about unexported method.
    59  func (ExportedType) unexportedMethod(a int) bool {
    60  	return true
    61  }
    62  
    63  // Constants tied to ExportedType. (The type is a struct so this isn't valid Go,
    64  // but it parses and that's all we need.)
    65  const (
    66  	ExportedTypedConstant ExportedType = iota
    67  )
    68  
    69  // Comment about constructor for exported type.
    70  func ExportedTypeConstructor() *ExportedType {
    71  	return nil
    72  }
    73  
    74  const unexportedTypedConstant ExportedType = 1 // In a separate section to test -u.
    75  
    76  // Comment about unexported type.
    77  type unexportedType int
    78  
    79  func (unexportedType) ExportedMethod() bool {
    80  	return true
    81  }
    82  
    83  func (unexportedType) unexportedMethod() bool {
    84  	return true
    85  }
    86  
    87  // Constants tied to unexportedType.
    88  const (
    89  	ExportedTypedConstant_unexported unexportedType = iota
    90  )
    91  
    92  const unexportedTypedConstant unexportedType = 1 // In a separate section to test -u.
    93  
    94  // For case matching.
    95  const CaseMatch = 1
    96  const Casematch = 2