github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/test/testdata/exhaustruct.go (about)

     1  //golangcitest:args -Eexhaustruct
     2  package testdata
     3  
     4  import "time"
     5  
     6  type Exhaustruct struct {
     7  	A string
     8  	B int
     9  	c bool // private field inside the same package are not ignored
    10  	D float64
    11  	E time.Time
    12  }
    13  
    14  func exhaustruct() {
    15  	// pass
    16  	_ = Exhaustruct{
    17  		A: "a",
    18  		B: 0,
    19  		c: false,
    20  		D: 1.0,
    21  		E: time.Now(),
    22  	}
    23  
    24  	// failPrivate
    25  	_ = Exhaustruct{ // want "testdata.Exhaustruct is missing field c"
    26  		A: "a",
    27  		B: 0,
    28  		D: 1.0,
    29  		E: time.Now(),
    30  	}
    31  
    32  	// fail
    33  	_ = Exhaustruct{ // want "testdata.Exhaustruct is missing field B"
    34  		A: "a",
    35  		c: false,
    36  		D: 1.0,
    37  		E: time.Now(),
    38  	}
    39  
    40  	// failMultiple
    41  	_ = Exhaustruct{ // want "testdata.Exhaustruct is missing fields B, D"
    42  		A: "a",
    43  		c: false,
    44  		E: time.Now(),
    45  	}
    46  
    47  }