goline icon indicating copy to clipboard operation
goline copied to clipboard

Support saving and loading history

Open nemith opened this issue 10 years ago • 1 comments

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.

nemith avatar Apr 14 '14 06:04 nemith

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 on History 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

mattyhall avatar Apr 14 '14 17:04 mattyhall