This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
state/Readme.md
2024-03-04 11:21:59 +01:00

836 B

State

From time to time i need some small state persistens like e.g. for a bot how count the numbers of messages with a special value. I want to store them somewhere to not cound double without thin king about it so i store a struct as json.

This pkg will provice Methodes to store (read and write) structs to the hdd.

Idear for later:

  • Store in S3 as well
  • Function for dealing with lists on store. Like add to list, chcik if exists in list and so on

Working with State

Write State to HDD

state, err := NewLocaleFilesystem("data/")
if err != nil {
    panic(err)
}

err = satate.StoreState("key", data)
if err != nil {
    panic(err)
}

Get State from HDD

state, err := NewLocaleFilesystem("data/")
if err != nil {
    panic(err)
}

err = satate.GetState("key", &data)
if err != nil {
    panic(err)
}