mirror of
https://github.com/tiennm99/gomoku.git
synced 2026-05-24 04:24:35 +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
32 lines
488 B
Go
32 lines
488 B
Go
package async
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"runtime"
|
|
)
|
|
|
|
func Async(fun func()) {
|
|
go func() {
|
|
defer func() {
|
|
if err := recover(); err != nil {
|
|
PrintStackTrace(err)
|
|
}
|
|
}()
|
|
fun()
|
|
}()
|
|
}
|
|
|
|
func PrintStackTrace(err interface{}) {
|
|
buf := bytes.Buffer{}
|
|
buf.WriteString(fmt.Sprintf("%v\n", err))
|
|
for i := 1; ; i++ {
|
|
pc, file, line, ok := runtime.Caller(i)
|
|
if !ok {
|
|
break
|
|
}
|
|
buf.WriteString(fmt.Sprintf("%s:%d (0x%x)\n", file, line, pc))
|
|
}
|
|
fmt.Println(buf.String())
|
|
}
|