removing go-sdk stuff

This commit is contained in:
Will Charczuk 2019-04-24 12:58:05 -07:00
parent 0576aba75e
commit 07a9cdf513
2 changed files with 6 additions and 10 deletions

View file

@ -4,15 +4,13 @@ import (
"bufio" "bufio"
"io" "io"
"os" "os"
"github.com/blend/go-sdk/exception"
) )
// ReadLines reads a file and calls the handler for each line. // ReadLines reads a file and calls the handler for each line.
func ReadLines(filePath string, handler func(string) error) error { func ReadLines(filePath string, handler func(string) error) error {
f, err := os.Open(filePath) f, err := os.Open(filePath)
if err != nil { if err != nil {
return exception.New(err) return err
} }
defer f.Close() defer f.Close()
@ -21,7 +19,7 @@ func ReadLines(filePath string, handler func(string) error) error {
line := scanner.Text() line := scanner.Text()
err = handler(line) err = handler(line)
if err != nil { if err != nil {
return exception.New(err) return err
} }
} }
return nil return nil
@ -31,7 +29,7 @@ func ReadLines(filePath string, handler func(string) error) error {
func ReadChunks(filePath string, chunkSize int, handler func([]byte) error) error { func ReadChunks(filePath string, chunkSize int, handler func([]byte) error) error {
f, err := os.Open(filePath) f, err := os.Open(filePath)
if err != nil { if err != nil {
return exception.New(err) return err
} }
defer f.Close() defer f.Close()
@ -44,7 +42,7 @@ func ReadChunks(filePath string, chunkSize int, handler func([]byte) error) erro
readData := chunk[:readBytes] readData := chunk[:readBytes]
err = handler(readData) err = handler(readData)
if err != nil { if err != nil {
return exception.New(err) return err
} }
} }
return nil return nil

View file

@ -4,8 +4,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/blend/go-sdk/exception"
) )
// ParseFloats parses a list of floats. // ParseFloats parses a list of floats.
@ -20,7 +18,7 @@ func ParseFloats(values ...string) ([]float64, error) {
continue continue
} }
if parsedValue, err = strconv.ParseFloat(cleaned, 64); err != nil { if parsedValue, err = strconv.ParseFloat(cleaned, 64); err != nil {
return nil, exception.New(err) return nil, err
} }
output = append(output, parsedValue) output = append(output, parsedValue)
} }
@ -34,7 +32,7 @@ func ParseTimes(layout string, values ...string) ([]time.Time, error) {
var err error var err error
for _, value := range values { for _, value := range values {
if parsedValue, err = time.Parse(layout, value); err != nil { if parsedValue, err = time.Parse(layout, value); err != nil {
return nil, exception.New(err) return nil, err
} }
output = append(output, parsedValue) output = append(output, parsedValue)
} }