mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-23 17:07:57 +08:00
20 lines
307 B
Go
20 lines
307 B
Go
|
package net2
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
// Returns the port information.
|
||
|
func GetPort(addr net.Addr) (int, error) {
|
||
|
_, lport, err := net.SplitHostPort(addr.String())
|
||
|
if err != nil {
|
||
|
return -1, err
|
||
|
}
|
||
|
lportInt, err := strconv.Atoi(lport)
|
||
|
if err != nil {
|
||
|
return -1, err
|
||
|
}
|
||
|
return lportInt, nil
|
||
|
}
|