From 484f81e1cea226267bb4256bb21ebaa1427d16d0 Mon Sep 17 00:00:00 2001 From: Ankush Agarwal Date: Sun, 28 Dec 2014 00:39:57 -0800 Subject: [PATCH] Fix doc typo and add additional if condition Signed-off-by: Ankush Agarwal --- state/state.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/state/state.go b/state/state.go index 655cb4f8c7..18f95e1507 100644 --- a/state/state.go +++ b/state/state.go @@ -1,6 +1,6 @@ package state -// State represents the state of a hosts +// State represents the state of a host type State int const ( @@ -25,9 +25,11 @@ var states = []string{ "Error", } +// Given a State type, returns its string representation func (s State) String() string { - if int(s) < len(states) { + if int(s) >= 0 && int(s) < len(states) { return states[s] + } else { + return "" } - return "" }