From 04a31f9fca2f5fc0b9cab67601d46575eb3dffae Mon Sep 17 00:00:00 2001 From: Ben Allen Date: Sat, 7 May 2016 23:10:59 -0500 Subject: [PATCH] Move some of the common functions to a utils file --- lib/util.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/util.go diff --git a/lib/util.go b/lib/util.go new file mode 100644 index 0000000..4e381a6 --- /dev/null +++ b/lib/util.go @@ -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 +}