Source file src/go/doc/testdata/examples/iota.go

     1  // Copyright 2021 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 foo_test
     6  
     7  const (
     8  	a = iota
     9  	b
    10  )
    11  
    12  const (
    13  	c = 3
    14  	d = 4
    15  )
    16  
    17  const (
    18  	e = iota
    19  	f
    20  )
    21  
    22  // The example refers to only one of the constants in the iota group, but we
    23  // must keep all of them because of the iota. The second group of constants can
    24  // be trimmed. The third has an iota, but is unused, so it can be eliminated.
    25  
    26  func Example() {
    27  	_ = b
    28  	_ = d
    29  }
    30  
    31  // Need two examples to hit the playExample function.
    32  
    33  func Example2() {
    34  }
    35  

View as plain text