atc0005 / go-nagios

Shared Golang package for Nagios plugins
MIT License
8 stars 3 forks source link

Add "append" helper methods #50

Open atc0005 opened 3 years ago

atc0005 commented 3 years ago

Optional methods to append to existing field content.

Example:

    nagiosExitState.LongServiceOutput = fmt.Sprintf(
        "* Paths: %v%s"+
            "* Recursive: %v%s"+
            "* Plugin: %v%s",
        cfg.Paths(),
        nagios.CheckOutputEOL,
        cfg.Recursive(),
        nagios.CheckOutputEOL,
        cfg.Version(),
        nagios.CheckOutputEOL,
    )

Instead of having to perform an "is string not empty" check before adding to the variable later, a method such as nagiosExitState.AppendLongServiceOutput (or nagiosExitState.AppendLSO or ...) could be used to handle that sort of logic.