mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 12:20:27 +08:00
优化代码
This commit is contained in:
@@ -4,7 +4,7 @@ package iputils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"encoding/hex"
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
@@ -111,10 +111,10 @@ func ToHex(ip string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if rawIP.To4() != nil {
|
if rawIP.To4() != nil {
|
||||||
return fmt.Sprintf("%x", rawIP.To4())
|
return hex.EncodeToString(rawIP.To4())
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%x", rawIP.To16())
|
return hex.EncodeToString(rawIP.To16())
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToLittleLong(ip string) string {
|
func ToLittleLong(ip string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user