Skip to content

Commit

Permalink
fix: add check for nil conn in snmp wrapper before attempting close
Browse files Browse the repository at this point in the history
  • Loading branch information
maier committed May 31, 2023
1 parent bdedbc3 commit e9dd116
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/snmp/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ func (gsw GosnmpWrapper) Host() string {

// Close returns the value of GoSNMP.Target.
func (gsw GosnmpWrapper) Close() error {
return gsw.Conn.Close()
if gsw.Conn != nil {
return gsw.Conn.Close()
}
return nil
}

// Walk wraps GoSNMP.Walk() or GoSNMP.BulkWalk(), depending on whether the
Expand Down

0 comments on commit e9dd116

Please sign in to comment.