選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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. }