goline
goline copied to clipboard
Support saving and loading history
Need a way to save and load history. Should use os.Reader and os.Writer as well as convenience functions to load and save from a file.
Hi, it's the person from reddit.
I added the helper functions in my fork of the project (https://github.com/mattyhall/go-goline). Hopefully everything is up to scratch, however some of it is a bit messy - particularly when, in history.Load
, the writer is turned into a bufio writer.
With regards to exposing this to the user I can think of a couple of ways of doing this:
- Pass a filename at start and automatically save after each enter
- Have a SaveHistory function on
GoLine
which calls the same function onHistory
which is called when the programme is done
Obviously if what I've done so far isn't too good feel free to say!
Thanks