mirror of
https://github.com/tiennm99/gomoku.git
synced 2026-05-27 12:24:39 +00:00
1b9eec5f7d
- 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
27 lines
592 B
Go
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)
|
|
}
|