github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/golang/lint/testdata/error-return.go (about)

     1  // Test for returning errors.
     2  
     3  // Package foo ...
     4  package foo
     5  
     6  // Returns nothing
     7  func f() { // ok
     8  }
     9  
    10  // Check for a single error return
    11  func g() error { // ok
    12  	return nil
    13  }
    14  
    15  // Check for a single other return type
    16  func h() int { // ok
    17  	return 0
    18  }
    19  
    20  // Check for multiple return but error at end.
    21  func i() (int, error) { // ok
    22  	return 0, nil
    23  }
    24  
    25  // Check for multiple return but error at end with named variables.
    26  func j() (x int, err error) { // ok
    27  	return 0, nil
    28  }
    29  
    30  // Check for error in the wrong location on 2 types
    31  func k() (error, int) { // MATCH /error should be the last type/
    32  	return nil, 0
    33  }
    34  
    35  // Check for error in the wrong location for > 2 types
    36  func l() (int, error, int) { // MATCH /error should be the last type/
    37  	return 0, nil, 0
    38  }
    39  
    40  // Check for error in the wrong location with named variables.
    41  func m() (x int, err error, y int) { // MATCH /error should be the last type/
    42  	return 0, nil, 0
    43  }