From cc0b2fd74f911ac84620c1d93730cabbda1e9093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 6 Apr 2024 10:07:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/iputils/ip.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/iputils/ip.go b/pkg/iputils/ip.go index 4c84e07..08d036a 100644 --- a/pkg/iputils/ip.go +++ b/pkg/iputils/ip.go @@ -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 {