added function ReadBnn to convert from reader directly

This commit is contained in:
Dom 2019-08-12 09:41:42 +02:00
parent a6f46be402
commit bd092d89dd
1 changed files with 12 additions and 1 deletions

13
bnn.go
View File

@ -2,6 +2,7 @@ package bnn
import ( import (
"bufio" "bufio"
"io"
"os" "os"
"strconv" "strconv"
"strings" "strings"
@ -122,7 +123,17 @@ func ReadBnnFile(path string) (Bnn, error) {
} }
defer file.Close() defer file.Close()
scanner := bufio.NewScanner(file) content, err := ReadBnn(file)
if err != nil {
return Bnn{}, err
}
return content, nil
}
// ReadBnn Reads from reader and returns object with all containing information
func ReadBnn(r io.Reader) (Bnn, error) {
scanner := bufio.NewScanner(r)
var lines []string var lines []string
for scanner.Scan() { for scanner.Scan() {