From b7cdd6bba5d5e0ef75d289cca206095c4b9a404b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Thu, 4 Aug 2022 14:52:50 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0[=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=BF=90=E8=90=A5=E5=95=86=E7=B1=BB=E5=9E=8B]=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get.go | 19 ++++++++++++++++++- get_test.go | 4 ++++ version.go | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/get.go b/get.go index 8ab6766..d0b24ba 100644 --- a/get.go +++ b/get.go @@ -1,6 +1,6 @@ package goverify -// 功能类型 +// 运营商名称 var typeName = map[string]string{ Mobile: "移动", Unicom: "联通", @@ -13,3 +13,20 @@ var typeName = map[string]string{ func GetTypeName(Type string) string { return typeName[Type] } + +// GetType 获取运营商类型 +func GetType(name string) (Type string) { + switch name { + case "移动", "移动运营商", "中国移动", "中国移动运营商": + return Mobile + case "联通", "联通运营商", "中国联通", "中国联通运营商": + return Unicom + case "电信", "电信运营商", "中国电信", "中国电信运营商": + return Telecom + case "广电", "广电运营商", "中国广电", "中国广电运营商": + return Broadnet + case "虚拟", "虚拟运营商": + return Virtual + } + return Type +} diff --git a/get_test.go b/get_test.go index bf13aa4..0996424 100644 --- a/get_test.go +++ b/get_test.go @@ -2,6 +2,10 @@ package goverify import "testing" +func TestGetType(t *testing.T) { + t.Log(GetType("移动")) +} + func TestGetTypeName(t *testing.T) { t.Log(GetTypeName(Mobile)) } diff --git a/version.go b/version.go index 80a395d..5bb5ae2 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package goverify -const Version = "1.0.6" +const Version = "1.0.7"