Fix doc typo and add additional if condition

Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
This commit is contained in:
Ankush Agarwal 2014-12-28 00:39:57 -08:00
parent 82965024ea
commit 484f81e1ce
1 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,6 @@
package state package state
// State represents the state of a hosts // State represents the state of a host
type State int type State int
const ( const (
@ -25,9 +25,11 @@ var states = []string{
"Error", "Error",
} }
// Given a State type, returns its string representation
func (s State) String() string { func (s State) String() string {
if int(s) < len(states) { if int(s) >= 0 && int(s) < len(states) {
return states[s] return states[s]
} } else {
return "" return ""
}
} }