Skip to content

Commit

Permalink
got my go build working; added nil-safe check also
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Koehn <brad@koehn.com>
  • Loading branch information
Brad Koehn committed Jan 30, 2020
1 parent 6acebe1 commit a16758f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/restic/exec_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ func decodeBackupStatusLine(lastLine []byte) (backupStatusLine, error) {
// have a newline at the end of it, so this returns the substring between the
// last two newlines.
func getLastLine(b []byte) []byte {
if b == nil {
return []byte("")
}
if len(b) == 0 {
return b
}
Expand Down
1 change: 1 addition & 0 deletions pkg/restic/exec_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ third line
assert.Equal(t, []byte(tt.want), getLastLine([]byte(tt.output)))
})
}
assert.Equal(t, []byte(""), getLastLine(nil))
}

func Test_getVolumeSize(t *testing.T) {
Expand Down

0 comments on commit a16758f

Please sign in to comment.