Files
gomoku/server/pkg/json/json.go
T
tiennm99 1b9eec5f7d refactor: rename Go module and copy core pkgs into server/pkg
- Module: github.com/ratel-online/server → github.com/tiennm99/gomoku/server
- Copied core/{log,util/async,util/json,util/strings,model,network,protocol,consts}
  into server/pkg/* (temporary shims until phase-05 replaces protocol/network)
- Rewrote all ratel-online import paths across server/**/*.go
- Trimmed main.go: single -p flag, WS-only on :1999, no TCP/bot/static
- Trimmed network/wss.go: endpoint /gomoku, no static file serving
- Updated Makefile: removed TCP/bot references, port 1999
2026-04-11 12:04:03 +07:00

27 lines
592 B
Go

package json
import (
jsoniter "github.com/json-iterator/go"
"unsafe"
)
func init() {
jsoniter.RegisterTypeEncoderFunc("[]uint8", func(ptr unsafe.Pointer, stream *jsoniter.Stream) {
t := *((*[]byte)(ptr))
stream.WriteString(string(t))
}, nil)
jsoniter.RegisterTypeDecoderFunc("[]uint8", func(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
str := iter.ReadString()
*((*[]byte)(ptr)) = []byte(str)
})
}
func Marshal(v interface{}) []byte {
data, _ := jsoniter.Marshal(v)
return data
}
func Unmarshal(data []byte, v interface{}) error {
return jsoniter.Unmarshal(data, v)
}