Skip to content

Commit

Permalink
use constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Jan 29, 2018
1 parent 1204b13 commit 3bc8778
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions check-ntpoffset/lib/check-ntpoffset.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ func getNTPOffsetFromNTPD() (offset float64, err error) {

func parseNTPOffsetFromNTPD(out io.Reader) (float64, error) {
scr := bufio.NewScanner(out)
prefix := "offset="
const offsetPrefix = "offset="
for scr.Scan() {
line := scr.Text()
if strings.HasPrefix(line, prefix) {
return strconv.ParseFloat(strings.TrimPrefix(line, prefix), 64)
if strings.HasPrefix(line, offsetPrefix) {
return strconv.ParseFloat(strings.TrimPrefix(line, offsetPrefix), 64)
}
}
return 0.0, fmt.Errorf("couldn't get ntp offset. ntpd process may be down")
Expand Down

0 comments on commit 3bc8778

Please sign in to comment.