Fix return nil (#15330)
* Fix return nil A nil error is an interface having nil value but a non-nil type. This leads to unexpected errors in the code well-documented here: https://golang.org/doc/faq#nil_error We fix this by passing an additional parameter to handle it. Caught using https://github.com/dgryski/semgrep-go * Bring back auto-generated line
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0eb63475a6
Коммит
94d09e1336
@@ -231,11 +231,15 @@ func generateLayer(name, templateFile string) ([]byte, error) {
|
||||
}
|
||||
return fmt.Sprintf("(%s)", strings.Join(results, ", "))
|
||||
},
|
||||
"genResultsVars": func(results []string) string {
|
||||
"genResultsVars": func(results []string, withNilError bool) string {
|
||||
vars := []string{}
|
||||
for i, typeName := range results {
|
||||
if isError(typeName) {
|
||||
vars = append(vars, "err")
|
||||
if withNilError {
|
||||
vars = append(vars, "nil")
|
||||
} else {
|
||||
vars = append(vars, "err")
|
||||
}
|
||||
} else if i == 0 {
|
||||
vars = append(vars, "result")
|
||||
} else {
|
||||
|
||||
Ссылка в новой задаче
Block a user