-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some of the common functions to a utils file
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |