In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "how to use Go language programs and diagnostic tools", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "how to use Go language procedures and diagnostic tools".
There must be no Java developers who don't know or use the jps command, which is used to see which Java programs are running on the host.
I was also very upset when I first used the Go language program. I deployed the Go program on the company server, and other colleagues often couldn't find it because I didn't know.
Is there a tool like jps in the Go language? Of course, not only, but also produced by Google itself, official certification (this kind of problem Google can not think of). The name is also very similar to jps, called gops.
Installation
Gops is not included in the official installation package and is not a standard tool. It needs to be obtained manually.
Go get-u github.com/google/gops
Easy to use
The use of goes is very simple, let's just take a look at the help documentation.
The simplest use is gops, which directly lists the running Go programs
The PID,PPID, program name, Go version number used for compilation, and program path are listed in turn. The information is more detailed than jps, which is good.
Not only that, gops can also diagnose programs.
Diagnosis
Someone may have noticed that there is a * sign behind my memory-test program above. This is because I added the diagnostic support code for gops to the program:
If err: = agent.Listen (agent.Options {ShutdownCleanup:true}); err! = nil {log.Fatalln (err)}
For such a program, we can execute commands such as gops pprof-cpu and gops pprof-heap. (stack, gc, setgc, memstats, version, stats, trace and other commands also need to be added to the above code).
The use is very simple, just paste a little picture directly, don't talk about it.
Because the go pprof command helps us analyze the program, it is relatively more commonly used. But in the past, it was relatively troublesome to use. Now that you have gops, it's convenient to analyze cpu and memory usage.
Gops not only supports local use, but also supports remote. View agent.Options:
You can set Addr to host:port form. My side is set to ": 9779". Deploy it to a remote server and run the command gops pprof-heap 192.168.199.210 9779, and you can see:
It's totally feasible. (note that not only all pprof-heap,gops commands support remote)
Add diagnostic code to our program, and it is also very convenient to analyze the program when deployed to a remote server.
The above is about the content of this article on "how to use Go language program viewing and diagnostic tools". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.