MCPcopy
hub / github.com/spf13/cobra / CheckErr

Function CheckErr

cobra.go:235–240  ·  view source on GitHub ↗

CheckErr prints the msg with the prefix 'Error:' and exits with error code 1. If the msg is nil, it does nothing.

(msg interface{})

Source from the content-addressed store, hash-verified

233
234// CheckErr prints the msg with the prefix 'Error:' and exits with error code 1. If the msg is nil, it does nothing.
235func CheckErr(msg interface{}) {
236 if msg != nil {
237 fmt.Fprintln(os.Stderr, "Error:", msg)
238 os.Exit(1)
239 }
240}
241
242// WriteStringAndCheck writes a string into a buffer, and checks if the error is not nil.
243func WriteStringAndCheck(b io.StringWriter, s string) {

Callers 6

ExampleGenManTreeFunction · 0.92
ExampleGenManFunction · 0.92
WriteStringAndCheckFunction · 0.85
runShellCheckFunction · 0.85
UsageStringMethod · 0.85
InitDefaultHelpCmdMethod · 0.85

Calls

no outgoing calls

Tested by 3

ExampleGenManTreeFunction · 0.74
ExampleGenManFunction · 0.74
runShellCheckFunction · 0.68