Skip to content

Commit

Permalink
Move some of the common functions to a utils file
Browse files Browse the repository at this point in the history
  • Loading branch information
bensallen committed May 8, 2016
1 parent 4563ab2 commit 04a31f9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package sastopo

func itob(i int) bool {
if i == 0 {
return false
}
return true
}

// trimPoints loops through a []byte looking for left trim and right trim points
// for trimming 0x00 (null) and 0x20 (ascii space)
func trimPoints(line []byte) (start int, stop int) {

//left trim point
for i := 0; i < len(line); i++ {
if line[i] == 0x20 || line[i] == 0x00 {
continue
} else {
start = i
break
}
}

//right trim point
for i := len(line) - 1; i >= 0; i-- {
if line[i] == 0x20 || line[i] == 0x00 {
continue
} else {
stop = i + 1
break
}
}
return start, stop
}

0 comments on commit 04a31f9

Please sign in to comment.