27 lines
352 B
Go
27 lines
352 B
Go
package nori
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func New() *Nori {
|
|
return &Nori{}
|
|
}
|
|
|
|
func FromFile(fp string) (*Nori, error) {
|
|
file, err := os.Open(fp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer file.Close()
|
|
return Decode(bufio.NewReader(file))
|
|
}
|
|
|
|
func Decode(r io.Reader) (*Nori, error) {
|
|
nori := New()
|
|
err := nori.Decode(r)
|
|
return nori, err
|
|
}
|