gophone

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2020 License: MIT, MIT Imports: 6 Imported by: 0

README

Build Status GoDoc

gophone

获取手机号码的归属地,邮编,卡的类型,区号,运营商等属性

Get PhoneNum's property, Such as Province, City, ZipCode, CardType, AreaZone, OperatorCompany

Complie

go get github.com/zheng-ji/gophone

Example

import (
	"fmt"
	"github.com/zheng-ji/gophone"
)

func main() {

	pr, err := gophone.Find("15920544678")
	if err == nil {
		fmt.Println(pr)
	}

	pr, err = gophone.Find("15920544678")
	if err == nil {
		// 也可以单独获取该号码各个属性
		fmt.Println(pr.PhoneNum)
		fmt.Println(pr.Province)
		fmt.Println(pr.AreaZone)
		fmt.Println(pr.City)
		fmt.Println(pr.ZipCode)
	}
}

OutPut

PhoneNum: 15920544678
AreaZone: 020
CardType: 移动虚拟运营商
City: 广州
ZipCode: 510000
Province: 广东

License

Copyright (c) 2015 by zheng-ji released under a MIT style license.

Thanks To the Data Provided by @loved

Documentation

Overview

* Copyright (c) 2015, zheng-ji.info *

Index

Constants

View Source
const (
	IntLen           = 4
	CharLen          = 1
	PhoneIndexLength = 9
	Chunk            = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GOPhone

type GOPhone struct {
	// contains filtered or unexported fields
}

func New

func New(phoneDat []byte) *GOPhone

func (*GOPhone) Display

func (g *GOPhone) Display()

func (*GOPhone) Find

func (g *GOPhone) Find(phoneNum string) (pr *PhoneRecord, err error)

BinarySearch

type PhoneRecord

type PhoneRecord struct {
	PhoneNum string
	Province string
	City     string
	ZipCode  string
	AreaZone string
	CardType string
}

func (PhoneRecord) String

func (pr PhoneRecord) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL