I am rewriting one of my windows service(C#) in Golang. I have almost figured out and rewrote the code in Go but got stuck at one place where I am not been able to figure out golang alternative.
public static int GetNumberOfLocalEstablishedConnectionsByPort(string IPAddress, int Port)
{
int Result = 0;
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections();
foreach (TcpConnectionInformation tcpInfo in tcpConnections)
{
if (tcpInfo.State == TcpState.Established && tcpInfo.LocalEndPoint.Port == Port)
{
Result++;
}
}
return Result;
}
Basically in this method I am finding out active number of connections based on a IP address and Port.
I am seeking help in order to find out how can I rewrite this C# code into Golang. I am using windows OS and want a solution based on Windows OS