Merge pull request #132 from ankushagarwal/state.go-fix

Fix doc typo and add additional if condition
This commit is contained in:
Evan Hazlett 2015-01-06 13:38:56 -08:00
commit ee9e4843b3
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 ""
} }