golang runtime-gdb.py的问题

问题:

(gdb) source /Users/sherlock/documents/go/src/runtime/runtime-gdb.py
Loading Go Runtime support.
Traceback (most recent call last):
  File "/Users/sherlock/documents/go/src/runtime/runtime-gdb.py", line 205, in <module>
    _rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
gdb.error: No struct type named runtime.rtype.

解决方案:

1. git clone https://github.com/golang/example.git

2.在stringutil目录下 go test -c ./

3.

gdb -q ./stringutil.test
Reading symbols from ./stringutil.test...done.
(gdb) source /usr/src/go/src/runtime/runtime-gdb.py
Loading Go Runtime support.
Traceback (most recent call last):
  File "/usr/src/go/src/runtime/runtime-gdb.py", line 205, in <module>
    _rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
gdb.error: No struct type named runtime.rtype.
(gdb) set pagination off
(gdb) set logging on
Copying output to gdb.txt.
(gdb) info types
# much output
(gdb) quit

4.命令行

grep runtime gdb.txt   | grep type;

5.得出结论

struct []*runtime._type;
typedef struct runtime.iface error;
typedef struct runtime.iface flag.Value;
typedef struct runtime.iface flag.boolFlag;
typedef struct runtime.iface fmt.Formatter;
typedef struct runtime.iface fmt.GoStringer;
typedef struct runtime.iface fmt.Scanner;
typedef struct runtime.iface fmt.Stringer;
typedef struct runtime.iface fmt.runeUnreader;
typedef void (struct runtime.g *) func(*runtime.g);
typedef void (struct runtime.stkframe *, void *, bool *) func(*runtime.stkframe, unsafe.Pointer) bool;
typedef void (struct []runtime.StackRecord, int *, bool *) func([]runtime.StackRecord) (int, bool);
typedef struct runtime.iface interface { runtime.f() };
typedef struct runtime.eface interface {};
typedef struct runtime.iface io.Reader;
typedef struct runtime.iface io.ReaderFrom;
typedef struct runtime.iface io.RuneReader;
typedef struct runtime.iface io.Writer;
typedef struct runtime.iface io.WriterTo;
typedef struct hash<string,*runtime/pprof.Profile> * map[string]*runtime/pprof.Profile;
typedef struct runtime.iface os.FileInfo;
typedef struct runtime.iface os.Signal;
typedef struct runtime.iface reflect.Type;
typedef struct runtime.iface regexp.input;
struct runtime._type;
typedef runtime.bucketType;
struct runtime.chantype;
typedef struct runtime.iface runtime.fInterface;
struct runtime.functype;
struct runtime.interfacetype;
typedef runtime.intptr;
struct runtime.maptype;
typedef runtime.pageID;
struct runtime.ptrtype;
struct runtime.slicetype;
typedef struct runtime.iface runtime.stringer;
struct runtime.typeAlg;
typedef runtime.uintreg;
struct runtime.uncommontype;
typedef struct runtime.iface runtime/pprof.countProfile;
typedef struct runtime.iface sort.Interface;
typedef struct runtime.iface sync.Locker;

6.修改runtime-gdb.py第205行rtype改成_type

注:我的平台是mac os x 10.10.3 ,go1.4.2

其他平台可能不是

struct []*runtime._type;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,我会尽力回答您的问题。首先,您需要安装 Go 和 Beego,以及 go-socket.io 库。可以使用以下命令安装 go-socket.io: ``` go get github.com/googollee/go-socket.io ``` 接下来,您需要创建一个 Beego 项目。可以使用以下命令创建一个名为 myproject 的项目: ``` bee new myproject ``` 然后,您需要在 main.go 文件中引入 go-socket.io 库,并创建一个 Socket.IO 服务器: ```go import ( "github.com/astaxie/beego" "github.com/googollee/go-socket.io" ) func main() { // 创建 Beego 应用 app := beego.NewApp() // 创建 Socket.IO 服务器 server, err := socketio.NewServer(nil) if err != nil { beego.Error(err) } defer server.Close() // 注册事件处理函数 server.On("connection", func(so socketio.Socket) { beego.Info("on connection") // 处理客户端连接事件 }) // 将 Socket.IO 服务器挂载到 Beego 应用 app.Router("/socket.io/", &SocketIOController{server}) beego.Run() } // SocketIOController 是一个 Beego 控制器,用于处理 Socket.IO 请求 type SocketIOController struct { server *socketio.Server } func (c *SocketIOController) Get() { c.server.ServeHTTP(c.Ctx.ResponseWriter, c.Ctx.Request) } ``` 最后,您需要在前端页面中使用 Socket.IO 客户端库来连接服务器并处理事件。以下是一个简单的示例: ```html <!DOCTYPE html> <html> <head> <title>Socket.IO Example</title> <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect(); socket.on('connect', function() { console.log('connected'); }); socket.on('message', function(data) { console.log('message received:', data); }); socket.emit('message', 'hello'); </script> </head> <body> <h1>Socket.IO Example</h1> </body> </html> ``` 这是一个简单的示例,您可以根据自己的需求进行修改和扩展。希望能对您有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值