英文:
Avoiding scrolling up when developing in Go
问题
我正在编写Go代码,同时有300个Go协程在运行。
当其中一个协程崩溃时,打印日志会变得非常长,我每次都需要向上滚动(我只需要看到日志的最后一行和第一个失败的协程)。
你是如何在Go中改善开发者体验的?
英文:
Iam writing go and I am having 300 go routines running at the same time.
When one of them crashes the print log becomes incredibly long and I endup scrolling up every time (I only need to see the last line of my log and the first go routine failing).
How are you making your developer experience nicer in go?
答案1
得分: 1
你可以将程序的输出导入到一个文件中:
./program 2>&1 > log.txt
或者导入到一个可以先查看缓冲区的程序中:
./program 2>&1 | less
2>&1
部分将标准输出和标准错误合并在一起,这样你就可以在同一个缓冲区中获取程序的输出和错误信息。
英文:
You can pipe the output of your program to a file
./program 2>&1 > log.txt
or to a program that lets you view the buffer head first
./program 2>&1 | less
The 2>&1
part combines stdout and stderr, so you get regular program output and error messages in the same buffer.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论