Files
2020-01-14 08:46:19 +11:00

30 lines
489 B
Go

package redhat
import (
"os"
)
type dataRow struct {
word string
count int
}
// FileAnalyser the command line which analysis text
type FileAnalyser struct {
file *os.File
dataRows []dataRow
}
// InitFromFile init analyser with file path, otherwise return error
func InitFromFile(filePath string) (*FileAnalyser, error) {
file, err := os.Open(filePath)
if err != nil {
return nil, err
}
return &FileAnalyser{
file: file,
dataRows: make([]dataRow, 0),
}, nil
}