https://github.com/netr/textfilego
Text File Line by Line Rotation Package with INI State Management
https://github.com/netr/textfilego
Last synced: 3 months ago
JSON representation
Text File Line by Line Rotation Package with INI State Management
- Host: GitHub
- URL: https://github.com/netr/textfilego
- Owner: netr
- Created: 2019-10-01T12:06:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-23T19:56:19.000Z (about 3 years ago)
- Last Synced: 2025-03-11T02:38:43.571Z (3 months ago)
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## TextFileGo
Thread Safe Text File Line by Line Rotation Package with INI State Management
---
Easy to use library to rotate through lines in text files. You can pick up wherever you left off using INI files to store the line number pointer. Must use \*.txt files for now. No tests yet. Can expand it/clean it up if anyone wants me to.
Works by loading all files in a directory into a struct.
```
var txts *textfiles.Files// initialize your text files from directory
txts = &textfiles.Files{}
err := txts.Init("/my-text-files/")
if err != nil {
log.Fatal(err)
return
}// will get next line for /my-text-files/filename.txt
// params for the Next function are (filename, roundRobin)// if you don't want it to round robin, the result will return an empty string
// you can use this to know it's finishedfmt.Printf("displaying line from filename: %s\n", txts.Next("filename", false))
// reset pointer
txts.ResetPointer("filename")
```