You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

serialization.go 571B

1234567891011121314151617181920212223
  1. package mysql
  2. import (
  3. "encoding/json"
  4. "github.com/ergochat/ergo/irc/history"
  5. "github.com/ergochat/ergo/irc/utils"
  6. )
  7. // 123 / '{' is the magic number that means JSON;
  8. // if we want to do a binary encoding later, we just have to add different magic version numbers
  9. func marshalItem(item *history.Item) (result []byte, err error) {
  10. return json.Marshal(item)
  11. }
  12. func unmarshalItem(data []byte, result *history.Item) (err error) {
  13. return json.Unmarshal(data, result)
  14. }
  15. func decodeMsgid(msgid string) ([]byte, error) {
  16. return utils.B32Encoder.DecodeString(msgid)
  17. }