phonenumber

package
v0.35.6 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	A2gCsvRelPath = "github.com/grokify/mogo/strconv/phonenumber/us-area-code-geo.csv"
)

Variables

This section is empty.

Functions

func A2gCsvFullPath

func A2gCsvFullPath() string

A2gCsvFullPath reads data from: https://github.com/ravisorg/Area-Code-Geolocation-Database

func E164Format

func E164Format(numberToParse, defaultRegion string, numberFormat phonenumbers.PhoneNumberFormat) (string, error)

func LetterToNumberMap

func LetterToNumberMap() map[string]int

func LocalNumberUS

func LocalNumberUS(ac uint16, ln uint16) uint64

LocalNumberUS returns a US E.164 number given an areacode and line number

func MustE164Format

func MustE164Format(numberToParse, defaultRegion string, numberFormat phonenumbers.PhoneNumberFormat) string

func NewPointString

func NewPointString(lat string, lon string) (*geo.Point, error)

NewPointString returns a *geo.Point based on string lat and lon values.

func StringToNumbers

func StringToNumbers(s string) string

Types

type AreaCodeIncrementor

type AreaCodeIncrementor struct {
	Counter map[uint16]uint16
	Base    uint16
}

func NewAreaCodeIncrementor

func NewAreaCodeIncrementor(base uint16) AreaCodeIncrementor

func (*AreaCodeIncrementor) GetNext

func (aci *AreaCodeIncrementor) GetNext(ac uint16) uint64

type AreaCodeInfo

type AreaCodeInfo struct {
	AreaCode uint16
	Point    *geo.Point
}

func NewAreaCodeInfoStrings

func NewAreaCodeInfoStrings(ac, lat, lon string) (AreaCodeInfo, error)

NewAreaCodeInfoStrings returns an AreaCodeInfo based on string area code, lat and lon values.

type AreaCodeToGeo

type AreaCodeToGeo struct {
	AreaCodeInfos  map[uint16]AreaCodeInfo
	DistanceMatrix map[uint16]map[uint16]float64
}

func NewAreaCodeToGeo

func NewAreaCodeToGeo() AreaCodeToGeo

func (*AreaCodeToGeo) AreaCodeSlice

func (a2g *AreaCodeToGeo) AreaCodeSlice() []AreaCodeInfo

func (*AreaCodeToGeo) AreaCodes

func (a2g *AreaCodeToGeo) AreaCodes() []uint16

func (*AreaCodeToGeo) AreaCodesSorted

func (a2g *AreaCodeToGeo) AreaCodesSorted() []uint16

func (*AreaCodeToGeo) GcdAreaCodes

func (a2g *AreaCodeToGeo) GcdAreaCodes(ac1Int uint16, ac2Int uint16) (float64, error)

func (*AreaCodeToGeo) GetDistanceMatrix

func (a2g *AreaCodeToGeo) GetDistanceMatrix() map[uint16]map[uint16]float64

func (*AreaCodeToGeo) Inflate

func (a2g *AreaCodeToGeo) Inflate()

func (*AreaCodeToGeo) ReadCsvPath

func (a2g *AreaCodeToGeo) ReadCsvPath(csvpath string) error

func (*AreaCodeToGeo) ReadData

func (a2g *AreaCodeToGeo) ReadData() error

type FakeNumberGenerator

type FakeNumberGenerator struct {
	AreaCodes []uint16
	Rand      *rand.Rand
}

func NewFakeNumberGenerator

func NewFakeNumberGenerator(areacodes []uint16) FakeNumberGenerator

func (*FakeNumberGenerator) LocalNumberUS

func (fng *FakeNumberGenerator) LocalNumberUS(ac uint16, ln uint16) uint64

LocalNumberUS returns a US E.164 number given an areacode and line number

func (*FakeNumberGenerator) RandomAreaCode

func (fng *FakeNumberGenerator) RandomAreaCode() uint16

RandomAreaCode generates a random area code.

func (*FakeNumberGenerator) RandomLineNumber

func (fng *FakeNumberGenerator) RandomLineNumber() uint16

RandomLineNumber generates a random line number

func (*FakeNumberGenerator) RandomLineNumberMinMax

func (fng *FakeNumberGenerator) RandomLineNumberMinMax(min, max uint16) uint16

RandomLineNumber generates a random line number

func (*FakeNumberGenerator) RandomLocalNumberUS

func (fng *FakeNumberGenerator) RandomLocalNumberUS() uint64

RandomLocalNumberUS returns a US E.164 number AreaCode + Prefix + Line Number

func (*FakeNumberGenerator) RandomLocalNumberUSAreaCodes

func (fng *FakeNumberGenerator) RandomLocalNumberUSAreaCodes(acs []uint16) uint64

RandomLocalNumberUS returns a US E.164 number AreaCode + Prefix + Line Number

func (*FakeNumberGenerator) RandomLocalNumberUSUnique

func (fng *FakeNumberGenerator) RandomLocalNumberUSUnique(set map[uint64]int8) (uint64, map[uint64]int8)

RandomLocalNumberUSUnique returns a US E.164 number AreaCode + Prefix + Line Number

func (*FakeNumberGenerator) RandomLocalNumberUSUniqueAreaCodeSet

func (fng *FakeNumberGenerator) RandomLocalNumberUSUniqueAreaCodeSet(set map[uint64]int8, acs []uint16) (uint64, map[uint64]int8)

RandomLocalNumberUSUnique returns a US E.164 number AreaCode + Prefix + Line Number

Jump to

Keyboard shortcuts

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