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
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
func Must(err error) {
if err != nil {
panic(err)
}
}
_, err := Write(data)
1. return err
// almost never
2. utilruntime.Must(err)
`utilruntime.Must(scheme.AddToScheme(clientsetscheme.Scheme))`
// almost never
3.
if err != nil {
log.Fatal(err)
}
You should use #2 or #3 based on the pattern present on that file. If neither is present, use #2 .
Test
1. return err
2. // fail test if error
if err != nil {
t.Fail(err)
}
3. Must(err)
4. _, _ = w.Write([]byte(authResp))
Video Explainer: https://www.youtube.com/watch?v=enDLuO-QL_Q