2

Is there a built in simple API/mechanism for reading/writing key/value pairs that need to persist across runs of your code?

I would normally use SQLite or something like that in Java, but if there is something built in to go that would be even better. (i.e. why depend on libraries when you don't need to)

Jay
  • 19,649
  • 38
  • 121
  • 184
  • 3
    "Using an in-memory map and writing snapshots to disk regularly (e.g. by using the gob package) is a good idea. The Practical Go Programming talk by Andrew Gerrand uses this technique." RE: http://stackoverflow.com/a/7756804/368552 – Luke Hutton Jun 30 '14 at 23:52
  • @LukeHutton I can use the search function too :D This posts links to a URL that no longer exists, and as far as I can tell, is not built in, requires some package called "gob" – Jay Jul 01 '14 at 00:07
  • 2
    Hehe, well those are built-in. And if you can search, you can find that talk too ;) – Luke Hutton Jul 01 '14 at 00:14
  • ...a bit of Googling turns up this: https://www.youtube.com/watch?v=2-pPAvqyluI – Simon Whitehead Jul 01 '14 at 00:20
  • 1
    @Jacob a simply web search for gob would have turned up [encoding/gob](http://golang.org/pkg/encoding/gob) – fuz Jul 01 '14 at 06:34
  • 2
    https://github.com/cznic/kv – thwd Jul 01 '14 at 08:35

1 Answers1

0

It is possible using one of the built in marshallers. For example, you can see the JSON marshal and un-marshal examples here:

http://golang.org/pkg/encoding/json/#example_Marshal

Jay
  • 19,649
  • 38
  • 121
  • 184