You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A good practice in Go when returning errors is to return nil or empty data for all other return values. It makes sure there is no other potential confusion on the calling end that the data returned is valid and could be used.
Here are some examples where we return data and an error.
This isn't the most precise methodology but currently my way of automating this is: for each subdirectory in src/ run ag "return .*\, err" ./src/$SUBDIR
with the goal of finding error returns without a nil/empty value return.
api
cmd
config (no error returns)
injector (not golang, as it turns out!)
internal
test
types
pkg
pkg (gets it own section)
cluster
interactive
layout
lint
message
pki
transform
utils
variables
zoci
While using using --ignore-dir={./src/pkg/packager,./src/internal/packager,./src/extensions}
If anyone has a sharper way of finding these errors ideas are very welcome.
A good practice in Go when returning errors is to return nil or empty data for all other return values. It makes sure there is no other potential confusion on the calling end that the data returned is valid and could be used.
Here are some examples where we return data and an error.
zarf/src/pkg/utils/yaml.go
Line 200 in f60b2f4
zarf/src/pkg/utils/io.go
Line 43 in f60b2f4
zarf/src/pkg/zoci/fetch.go
Line 20 in f60b2f4
zarf/src/pkg/cluster/zarf.go
Line 281 in f60b2f4
This is slightly related to #2950 and could be done in conjunction with it.
The text was updated successfully, but these errors were encountered: