added function ReadBnn to convert from reader directly
This commit is contained in:
parent
a6f46be402
commit
bd092d89dd
13
bnn.go
13
bnn.go
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue