Black Lives Matter. Support the Equal Justice Initiative.

Source file test/initempty.go

Documentation: test

     1  // run
     2  
     3  // Copyright 2019 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Test that empty init functions are skipped.
     8  
     9  package main
    10  
    11  import _ "unsafe" // for go:linkname
    12  
    13  type initTask struct {
    14  	state uintptr
    15  	ndeps uintptr
    16  	nfns  uintptr
    17  }
    18  
    19  //go:linkname main_inittask main..inittask
    20  var main_inittask initTask
    21  
    22  func main() {
    23  	if nfns := main_inittask.nfns; nfns != 0 {
    24  		println(nfns)
    25  		panic("unexpected init funcs")
    26  	}
    27  }
    28  
    29  func init() {
    30  }
    31  
    32  func init() {
    33  	if false {
    34  	}
    35  }
    36  
    37  func init() {
    38  	for false {
    39  	}
    40  }
    41  

View as plain text