-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/expose process info #6
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, it would be better to introduce go module support in a separate commit.
pid int | ||
name string | ||
Pid int | ||
Name string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense, a few people already asked me to export these fields.
if err != nil { | ||
return nil, err | ||
} | ||
binary.LittleEndian.PutUint32(ip[i:j], uint32(u)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
n, err := stat.Read(buf[:]) | ||
stat.Close() | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong. You don't need to check for nil there. os.Open
always returns non-nil
value if it succeeded. Check the source code for os.Open.
@@ -253,8 +255,10 @@ func doNetstat(path string, fn AcceptFn) ([]SockTabEntry, error) { | |||
if err != nil { | |||
return nil, err | |||
} | |||
if f != nil { | |||
defer f.Close() | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, again, the same situation as above. Nil-check is unnecessary here as the
os.Open already succeeded.
No description provided.