title: How to find the ports that is being used by a process in golang or in general?
body: <p>My binary takes a port parameter and starts a http server. If pass a 0 to the -port, it will find a free port and start on it.</p>
  
  <p>After this, how do I find which port is this if I have the command object with me and can get the process id? I am trying to write my application in golang. I am also curious how this is done in general.</p>