Documentation ¶
Index ¶
- Constants
- func A2gCsvFullPath() string
- func E164Format(numberToParse, defaultRegion string, ...) (string, error)
- func LetterToNumberMap() map[string]int
- func LocalNumberUS(ac uint16, ln uint16) uint64
- func MustE164Format(numberToParse, defaultRegion string, ...) string
- func NewPointString(lat string, lon string) (*geo.Point, error)
- func StringToNumbers(s string) string
- type AreaCodeIncrementor
- type AreaCodeInfo
- type AreaCodeToGeo
- func (a2g *AreaCodeToGeo) AreaCodeSlice() []AreaCodeInfo
- func (a2g *AreaCodeToGeo) AreaCodes() []uint16
- func (a2g *AreaCodeToGeo) AreaCodesSorted() []uint16
- func (a2g *AreaCodeToGeo) GcdAreaCodes(ac1Int uint16, ac2Int uint16) (float64, error)
- func (a2g *AreaCodeToGeo) GetDistanceMatrix() map[uint16]map[uint16]float64
- func (a2g *AreaCodeToGeo) Inflate()
- func (a2g *AreaCodeToGeo) ReadCsvPath(csvpath string) error
- func (a2g *AreaCodeToGeo) ReadData() error
- type CarrierNumberInfo
- type Components
- type FakeNumberGenerator
- func (fng *FakeNumberGenerator) LocalNumberUS(ac uint16, ln uint16) uint64
- func (fng *FakeNumberGenerator) RandomAreaCode() uint16
- func (fng *FakeNumberGenerator) RandomLineNumber() uint16
- func (fng *FakeNumberGenerator) RandomLineNumberMinMax(min, max uint16) uint16
- func (fng *FakeNumberGenerator) RandomLocalNumberUS() (uint64, error)
- func (fng *FakeNumberGenerator) RandomLocalNumberUSAreaCodes(acs []uint16) uint64
- func (fng *FakeNumberGenerator) RandomLocalNumberUSUnique(set map[uint64]int8) (uint64, map[uint64]int8, error)
- func (fng *FakeNumberGenerator) RandomLocalNumberUSUniqueAreaCodeSet(set map[uint64]int8, acs []uint16) (uint64, map[uint64]int8, error)
- type Lookup
- type LookupSet
- type MapStringString
- type Number
- type NumberSet
- func (set *NumberSet) Add(num Number) error
- func (set *NumberSet) HistogramCarrierName() map[string]int
- func (set *NumberSet) MapNumberCarrierName() map[string]string
- func (set *NumberSet) MapNumberLineType() map[string]string
- func (set *NumberSet) RemoveLookups()
- func (set *NumberSet) Validate() error
- func (set *NumberSet) WriteFileJSON(filename, prefix, indent string, perm fs.FileMode) error
Constants ¶
const ( CarrierATT = "att" CarrierSprint = "sprint" CarrierTMobile = "tmobile" CarrierVerizon = "verizon" LineTypeLocal = "local" LineTypeMobile = "mobile" LineTypeTollFree = "tollfree" SourceEkata = "ekata" SourceNumverify = "numverify" SourcePlivo = "plivo" SourceTwilio = "twilio" )
const (
A2gCsvRelPath = "github.com/grokify/mogo/strconv/phonenumber/us-area-code-geo.csv"
)
Variables ¶
This section is empty.
Functions ¶
func A2gCsvFullPath ¶ added in v0.3.0
func A2gCsvFullPath() string
A2gCsvFullPath reads data from: https://github.com/ravisorg/Area-Code-Geolocation-Database
func E164Format ¶ added in v0.3.0
func E164Format(numberToParse, defaultRegion string, numberFormat phonenumbers.PhoneNumberFormat) (string, error)
func LetterToNumberMap ¶ added in v0.3.0
func LocalNumberUS ¶ added in v0.3.0
LocalNumberUS returns a US E.164 number given an areacode and line number
func MustE164Format ¶ added in v0.3.0
func MustE164Format(numberToParse, defaultRegion string, numberFormat phonenumbers.PhoneNumberFormat) string
func NewPointString ¶ added in v0.3.0
NewPointString returns a *geo.Point based on string lat and lon values.
func StringToNumbers ¶ added in v0.3.0
Types ¶
type AreaCodeIncrementor ¶ added in v0.3.0
func NewAreaCodeIncrementor ¶ added in v0.3.0
func NewAreaCodeIncrementor(base uint16) AreaCodeIncrementor
func (*AreaCodeIncrementor) GetNext ¶ added in v0.3.0
func (aci *AreaCodeIncrementor) GetNext(ac uint16) uint64
type AreaCodeInfo ¶ added in v0.3.0
func NewAreaCodeInfoStrings ¶ added in v0.3.0
func NewAreaCodeInfoStrings(ac, lat, lon string) (AreaCodeInfo, error)
NewAreaCodeInfoStrings returns an AreaCodeInfo based on string area code, lat and lon values.
type AreaCodeToGeo ¶ added in v0.3.0
type AreaCodeToGeo struct { AreaCodeInfos map[uint16]AreaCodeInfo DistanceMatrix map[uint16]map[uint16]float64 }
func NewAreaCodeToGeo ¶ added in v0.3.0
func NewAreaCodeToGeo() AreaCodeToGeo
func (*AreaCodeToGeo) AreaCodeSlice ¶ added in v0.3.0
func (a2g *AreaCodeToGeo) AreaCodeSlice() []AreaCodeInfo
func (*AreaCodeToGeo) AreaCodes ¶ added in v0.3.0
func (a2g *AreaCodeToGeo) AreaCodes() []uint16
func (*AreaCodeToGeo) AreaCodesSorted ¶ added in v0.3.0
func (a2g *AreaCodeToGeo) AreaCodesSorted() []uint16
func (*AreaCodeToGeo) GcdAreaCodes ¶ added in v0.3.0
func (a2g *AreaCodeToGeo) GcdAreaCodes(ac1Int uint16, ac2Int uint16) (float64, error)
func (*AreaCodeToGeo) GetDistanceMatrix ¶ added in v0.3.0
func (a2g *AreaCodeToGeo) GetDistanceMatrix() map[uint16]map[uint16]float64
func (*AreaCodeToGeo) Inflate ¶ added in v0.3.0
func (a2g *AreaCodeToGeo) Inflate()
func (*AreaCodeToGeo) ReadCsvPath ¶ added in v0.3.0
func (a2g *AreaCodeToGeo) ReadCsvPath(csvpath string) error
func (*AreaCodeToGeo) ReadData ¶ added in v0.3.0
func (a2g *AreaCodeToGeo) ReadData() error
type CarrierNumberInfo ¶ added in v0.2.0
type CarrierNumberInfo struct { E164Number string `json:"e164Number"` MobileCountryCode string `json:"mobileCountryCode,omitempty"` MobileNetworkCode string `json:"mobileNetworkCode,omitempty"` Name string `json:"name,omitempty"` LineType string `json:"lineType,omitempty"` ErrorCode string `json:"errorCode,omitempty"` }
type Components ¶
type FakeNumberGenerator ¶ added in v0.3.0
type FakeNumberGenerator struct {
AreaCodes []uint16
}
func NewFakeNumberGenerator ¶ added in v0.3.0
func NewFakeNumberGenerator(areacodes []uint16) FakeNumberGenerator
func (*FakeNumberGenerator) LocalNumberUS ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (fng *FakeNumberGenerator) RandomAreaCode() uint16
RandomAreaCode generates a random area code.
func (*FakeNumberGenerator) RandomLineNumber ¶ added in v0.3.0
func (fng *FakeNumberGenerator) RandomLineNumber() uint16
RandomLineNumber generates a random line number
func (*FakeNumberGenerator) RandomLineNumberMinMax ¶ added in v0.3.0
func (fng *FakeNumberGenerator) RandomLineNumberMinMax(min, max uint16) uint16
RandomLineNumber generates a random line number
func (*FakeNumberGenerator) RandomLocalNumberUS ¶ added in v0.3.0
func (fng *FakeNumberGenerator) RandomLocalNumberUS() (uint64, error)
RandomLocalNumberUS returns a US E.164 number AreaCode + Prefix + Line Number
func (*FakeNumberGenerator) RandomLocalNumberUSAreaCodes ¶ added in v0.3.0
func (fng *FakeNumberGenerator) RandomLocalNumberUSAreaCodes(acs []uint16) uint64
RandomLocalNumberUS returns a US E.164 number AreaCode + Prefix + Line Number
func (*FakeNumberGenerator) RandomLocalNumberUSUnique ¶ added in v0.3.0
func (fng *FakeNumberGenerator) RandomLocalNumberUSUnique(set map[uint64]int8) (uint64, map[uint64]int8, error)
RandomLocalNumberUSUnique returns a US E.164 number AreaCode + Prefix + Line Number
func (*FakeNumberGenerator) RandomLocalNumberUSUniqueAreaCodeSet ¶ added in v0.3.0
func (fng *FakeNumberGenerator) RandomLocalNumberUSUniqueAreaCodeSet(set map[uint64]int8, acs []uint16) (uint64, map[uint64]int8, error)
RandomLocalNumberUSUnique returns a US E.164 number AreaCode + Prefix + Line Number
type Lookup ¶ added in v0.2.0
type Lookup struct { CarrierNumberInfo CarrierNumberInfo `json:"carrierNumberInfo"` LookupSource string `json:"lookupSource"` LookupTime time.Time `json:"lookupTime"` LookupResponse map[string]interface{} `json:"lookupResponse"` }
type LookupSet ¶ added in v0.2.0
func NewLookupSet ¶ added in v0.2.0
func NewLookupSet() LookupSet
type MapStringString ¶ added in v0.2.0
type Number ¶ added in v0.2.0
type Number struct { E164Number string `json:"e164Number"` CountryCode string `json:"countryCode"` CarrierNumberInfo CarrierNumberInfo `json:"carrier"` Lookups LookupSet `json:"lookups"` }
func (*Number) NANPComponents ¶ added in v0.2.0
func (num *Number) NANPComponents() (Components, error)
func (*Number) RemoveLookups ¶ added in v0.3.0
func (num *Number) RemoveLookups()
type NumberSet ¶ added in v0.2.0
func NewNumberSet ¶ added in v0.2.0
func NewNumberSet() NumberSet
func (*NumberSet) HistogramCarrierName ¶ added in v0.3.0
func (*NumberSet) MapNumberCarrierName ¶ added in v0.2.0
func (*NumberSet) MapNumberLineType ¶ added in v0.2.0
func (*NumberSet) RemoveLookups ¶ added in v0.3.0
func (set *NumberSet) RemoveLookups()