Protogen Goroutine 堆栈超出

问题描述 投票:0回答:1

最近我在 golang 中遇到了代码生成问题。我有一个巨大的原始文件,现在需要使用外部包向大多数消息添加日志记录。但是,如果我为太多字段添加日志记录,则会出现恐慌,并表示 goroutine 堆栈超出。有没有办法按块生成代码,或者仅增加生成的 goroutine 最大缓存大小?

我尝试 debug.SetMaxStack 并使用 go 代码运行生成命令,但没有任何改变,这对我来说似乎不是一个好的解决方案

go protocol-buffers code-generation
1个回答
0
投票

事实证明问题是,正如 @BurakSerdar 在评论递归打印循环中所说。 所以如果你有类似的东西:

message human {
  string name = 1;
  human child = 2;
  human parent = 3;
}

你不应该这样做:

message human {
  string name = 1;
  human child = 2 [(logger.field) = true];
  human parent = 3;
}

我相信您想要添加到字段的其他自定义内容也是如此,如果您有消息,包含具有相同消息类型的字段

© www.soinside.com 2019 - 2024. All rights reserved.