github.com/nozzle/golangci-lint@v1.49.0-nz3/test/testdata/exhaustruct_custom.go (about)

     1  //golangcitest:args -Eexhaustruct
     2  //golangcitest:config_path testdata/configs/exhaustruct.yml
     3  package testdata
     4  
     5  import "time"
     6  
     7  type ExhaustructCustom struct {
     8  	A string
     9  	B int
    10  	c bool // private field inside the same package are not ignored
    11  	D float64
    12  	E time.Time
    13  }
    14  
    15  func exhaustructCustom() {
    16  	// pass
    17  	_ = ExhaustructCustom{
    18  		A: "a",
    19  		B: 0,
    20  		c: false,
    21  		D: 1.0,
    22  		E: time.Now(),
    23  	}
    24  
    25  	// fail
    26  	_ = ExhaustructCustom{ // want "B is missing in ExhaustructCustom"
    27  		A: "a",
    28  		c: false,
    29  		D: 1.0,
    30  		E: time.Now(),
    31  	}
    32  
    33  	// failMultiple
    34  	_ = ExhaustructCustom{ // want "B, D are missing in ExhaustructCustom"
    35  		A: "a",
    36  		c: false,
    37  		E: time.Now(),
    38  	}
    39  
    40  	//  failPrivate
    41  	_ = ExhaustructCustom{ // want "c is missing in ExhaustructCustom"
    42  		A: "a",
    43  		B: 0,
    44  		D: 1.0,
    45  		E: time.Now(),
    46  	}
    47  
    48  }
    49  
    50  type ExhaustructCustom1 struct {
    51  	A string
    52  	B int
    53  	c bool // private field inside the same package are not ignored
    54  	D float64
    55  	E time.Time
    56  }
    57  
    58  func exhaustructCustom1() {
    59  	// pass
    60  	_ = ExhaustructCustom{
    61  		A: "a",
    62  		B: 0,
    63  		c: false,
    64  		D: 1.0,
    65  		E: time.Now(),
    66  	}
    67  
    68  	// fail
    69  	_ = ExhaustructCustom1{
    70  		A: "a",
    71  		c: false,
    72  		D: 1.0,
    73  		E: time.Now(),
    74  	}
    75  
    76  	// failMultiple
    77  	_ = ExhaustructCustom1{
    78  		A: "a",
    79  		c: false,
    80  		E: time.Now(),
    81  	}
    82  
    83  	// failPrivate
    84  	_ = ExhaustructCustom1{
    85  		A: "a",
    86  		B: 0,
    87  		D: 1.0,
    88  		E: time.Now(),
    89  	}
    90  
    91  }
    92  
    93  type ExhaustructCustom2 struct {
    94  	A string
    95  	B int
    96  	c bool // private field inside the same package are not ignored
    97  	D float64
    98  	E time.Time
    99  }
   100  
   101  func exhaustructCustom2() {
   102  	// pass
   103  	_ = ExhaustructCustom2{
   104  		A: "a",
   105  		B: 0,
   106  		c: false,
   107  		D: 1.0,
   108  		E: time.Now(),
   109  	}
   110  
   111  	// fail
   112  	_ = ExhaustructCustom2{
   113  		A: "a",
   114  		c: false,
   115  		D: 1.0,
   116  		E: time.Now(),
   117  	}
   118  
   119  	// failMultiple
   120  	_ = ExhaustructCustom2{
   121  		A: "a",
   122  		c: false,
   123  		E: time.Now(),
   124  	}
   125  
   126  	// failPrivate
   127  	_ = ExhaustructCustom2{
   128  		A: "a",
   129  		B: 0,
   130  		D: 1.0,
   131  		E: time.Now(),
   132  	}
   133  }