From df5e49abe5d269e6fd1cb43c0f7abae556d65c22 Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Thu, 17 Oct 2024 07:21:25 -0500 Subject: [PATCH] Fix `Plugin.SetOutputTarget` fallback behavior Correctly fallback to default output target when an invalid output target is provided. refs GH-267 --- nagios.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nagios.go b/nagios.go index f1b43df..6903185 100644 --- a/nagios.go +++ b/nagios.go @@ -467,11 +467,14 @@ func (p *Plugin) AddUniqueError(errs ...error) { } // SetOutputTarget assigns a target for Nagios plugin output. By default -// output is emitted to os.Stdout. +// output is emitted to os.Stdout. If given an invalid output target the +// default output target will be used instead. func (p *Plugin) SetOutputTarget(w io.Writer) { // Guard against potential nil argument. if w == nil { p.outputSink = os.Stdout + + return } p.outputSink = w