优化代码

This commit is contained in:
刘祥超
2024-04-06 10:07:47 +08:00
parent e54cfa7765
commit cc0b2fd74f

View File

@@ -4,7 +4,7 @@ package iputils
import (
"encoding/binary"
"fmt"
"encoding/hex"
"math"
"math/big"
"net"
@@ -111,10 +111,10 @@ func ToHex(ip string) string {
}
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 {