From ef05c668f9df64a3f6729b0dabc729baa4a95313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Thu, 5 May 2022 20:43:43 +0800 Subject: [PATCH] update --- .gitignore | 1 - app_test.go | 23 +++++++++++++++++++++++ ip_test.go | 15 +++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 app_test.go create mode 100644 ip_test.go diff --git a/.gitignore b/.gitignore index c316f13..114804c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,5 @@ .idea .vscode *.log -*_test.go gomod.sh /vendor/ diff --git a/app_test.go b/app_test.go new file mode 100644 index 0000000..7fe1acb --- /dev/null +++ b/app_test.go @@ -0,0 +1,23 @@ +package goip + +import ( + "net" + "testing" +) + +var app App + +func TestOnlineDownload(t *testing.T) { + //t.Log(app.V4db.OnlineDownload()) // 在线下载ipv4数据库 + //t.Log(app.V6db.OnlineDownload()) // 在线下载ipv6数据库 +} + +func TestIp(t *testing.T) { + app.InitIPData() + t.Logf("%+v", net.ParseIP("61.241.55.180").To4()) + t.Logf("%+v", net.ParseIP("240e:3b4:38e4:3295:7093:af6c:e545:f2e9").To16()) + t.Logf("%+v", app.V4db.Find("61.241.55.180")) + t.Logf("%+v", app.V4db.Find("116.7.98.130")) + t.Logf("%+v", app.V6db.Find("240e:3b4:38e4:3295:7093:af6c:e545:f2e9")) + t.Log(app.V4Region.MemorySearch("61.241.55.180")) +} diff --git a/ip_test.go b/ip_test.go new file mode 100644 index 0000000..7b94663 --- /dev/null +++ b/ip_test.go @@ -0,0 +1,15 @@ +package goip + +import "testing" + +func TestGetOutsideIp(t *testing.T) { + t.Log(GetOutsideIp()) +} + +func TestGetInsideIp(t *testing.T) { + t.Log(GetInsideIp()) +} + +func TestIps(t *testing.T) { + t.Log(Ips()) +}