// from google/cayley func persist(term *liner.State, path string) error { f, err := os.OpenFile(path, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666) if err != nil { return fmt.Errorf("could not open %q to append history: %v", path, err) } defer f.Close() _, err = term.WriteHistory(f) if err != nil { return fmt.Errorf("could not write history to %q: %v", path, err) } return term.Close() }