func ToPhone(theString, delimiter string) (string, error) {
	f := New(theString)
	f.removeNonDigits()

	if f.length < 10 {
		return "", errors.New(lengthError)
	}

	var buffer bytes.Buffer
	count := 0
	switch f.length {
	case 10:
		buffer.WriteString("(")
		for _, i := range f.theString {
			count++
			buffer.WriteString(string(i))
			switch count {
			case 3:
				buffer.WriteString(") ")
			case 6:
				buffer.WriteString(fmt.Sprintf("%s", delimiter))
			}
		}
	case 11:
		for _, i := range f.theString {
			count++
			buffer.WriteString(string(i))
			switch count {
			case 1:
				buffer.WriteString(" (")
			case 4:
				buffer.WriteString(") ")
			case 7:
				buffer.WriteString(fmt.Sprintf("%s", delimiter))
			}
		}
	default:
		return "", errors.New("non US number given")
	}
	return buffer.String(), nil
}
func ToPhone(theString, delimiter string) (string, error) {
	f := New(theString)
	f.removeNonDigits()

	if f.length < 10 {
		return "", errors.New(lengthError)
	}

	var buffer bytes.Buffer
	count := 0
	switch f.length {
	case 10:
		buffer.WriteString("(")
		for _, i := range f.theString {
			count++
			buffer.WriteString(string(i))
			switch count {
			case 3:
				buffer.WriteString(") ")
			case 6:
				buffer.WriteString(fmt.Sprintf("%s", delimiter))
			}
		}
	case 11:
		for _, i := range f.theString {
			count++
			buffer.WriteString(string(i))
			switch count {
			case 1:
				buffer.WriteString(" (")
			case 4:
				buffer.WriteString(") ")
			case 7:
				buffer.WriteString(fmt.Sprintf("%s", delimiter))
			}
		}
	default:
		return "", errors.New("non US number given")
	}
	return buffer.String(), nil
}
func ToPhone ( theString , delimiter string ) ( string , error ) { f := New ( theString ) f . removeNonDigits ( ) if f . length < 10 { return " " , errors . New ( lengthError ) } var buffer bytes . Buffer count := 0 switch f . length { case 10 : buffer . WriteString ( " " ) for _ , i := range f . theString { count ++ buffer . WriteString ( string ( i ) ) switch count { case 3 : buffer . WriteString ( " " ) case 6 : buffer . WriteString ( fmt . Sprintf ( " " , delimiter ) ) } } case 11 : for _ , i := range f . theString { count ++ buffer . WriteString ( string ( i ) ) switch count { case 1 : buffer . WriteString ( " " ) case 4 : buffer . WriteString ( " " ) case 7 : buffer . WriteString ( fmt . Sprintf ( " " , delimiter ) ) } } default : return " " , errors . New ( " " ) } return buffer . String ( ) , nil }
// ToPhone will format the provided string as a Phone Number.  Only supports
// US numbers currently.
ToPhone will format the provided string as a Phone Number . Only supports US numbers currently .