mirror of
https://github.com/wahyd4/redhat.git
synced 2026-08-08 20:24:47 +10:00
30 lines
489 B
Go
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
|
|
}
|