Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountryCode ¶
CountryCode returns the country code for the supplied number
func IsPossibleNumber ¶
IsPossibleNumber can be used for quickly guessing whether a number is a possible phonenumber by using only the length information, much faster than a full validation.
Example ¶
number := "+358401231234" defaultRegion := "FI" possibleNumber := phonenumber.IsPossibleNumber(number, defaultRegion) fmt.Printf("The number %s is possible phone number in region %s: %v", number, defaultRegion, possibleNumber)
Output: The number +358401231234 is possible phone number in region FI: true
Types ¶
type Error ¶
type Error string
Error represents errors when handling phone numbers
func (*Error) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Error) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type PhoneNumber ¶
type PhoneNumber struct { // Original number given to the function Number string `json:"number"` // Number in normalized format (E164) Normalized *string `json:"normalized"` // Any error given Error *Error `json:"error"` // If the number was valid in the first place Valid bool `json:"valid"` }
PhoneNumber stores information about a number
func Parse ¶
func Parse(number, region string) PhoneNumber
Parse parses a phone number
Example ¶
number := "040 123 1234" defaultRegion := "FI" info := phonenumber.Parse(number, defaultRegion) fmt.Printf("The number %s in normalized format is %s and validity is %v", info.Number, *info.Normalized, info.Valid)
Output: The number 040 123 1234 in normalized format is +358401231234 and validity is true
Click to show internal directories.
Click to hide internal directories.