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

     1  // Copyright 2012 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  // Test cases for sort order of declarations.
     6  
     7  package d
     8  
     9  // C2 should be third.
    10  const C2 = 2
    11  
    12  // V2 should be third.
    13  var V2 int
    14  
    15  // CBx constants should appear before CAx constants.
    16  const (
    17  	CB2 = iota // before CB1
    18  	CB1        // before CB0
    19  	CB0        // at end
    20  )
    21  
    22  // VBx variables should appear before VAx variables.
    23  var (
    24  	VB2 int // before VB1
    25  	VB1 int // before VB0
    26  	VB0 int // at end
    27  )
    28  
    29  const (
    30  	// Single const declarations inside ()'s are considered ungrouped
    31  	// and show up in sorted order.
    32  	Cungrouped = 0
    33  )
    34  
    35  var (
    36  	// Single var declarations inside ()'s are considered ungrouped
    37  	// and show up in sorted order.
    38  	Vungrouped = 0
    39  )
    40  
    41  // T2 should be third.
    42  type T2 struct{}
    43  
    44  // Grouped types are sorted nevertheless.
    45  type (
    46  	// TG2 should be third.
    47  	TG2 struct{}
    48  
    49  	// TG1 should be second.
    50  	TG1 struct{}
    51  
    52  	// TG0 should be first.
    53  	TG0 struct{}
    54  )
    55  
    56  // F2 should be third.
    57  func F2() {}