code: func FormatWithBuf(
  	number *PhoneNumber,
  	numberFormat PhoneNumberFormat,
  	formattedNumber *builder.Builder) {
  	// Clear the StringBuilder first.
  	formattedNumber.Reset()
  	countryCallingCode := int(number.GetCountryCode())
  	nationalSignificantNumber := GetNationalSignificantNumber(number)
  
  	if numberFormat == E164 {
  		// Early exit for E164 case (even if the country calling code
  		// is invalid) since no formatting of the national number needs
  		// to be applied. Extensions are not formatted.
  		formattedNumber.WriteString(nationalSignificantNumber)
  		prefixNumberWithCountryCallingCode(
  			countryCallingCode,
  			E164,
  			formattedNumber)
  		return
  	} else if !hasValidCountryCallingCode(countryCallingCode) {
  		formattedNumber.WriteString(nationalSignificantNumber)
  		return
  	}
  	// Note GetRegionCodeForCountryCode() is used because formatting
  	// information for regions which share a country calling code is
  	// contained by only one region for performance reasons. For
  	// example, for NANPA regions it will be contained in the metadata for US.
  	regionCode := GetRegionCodeForCountryCode(countryCallingCode)
  	// Metadata cannot be null because the country calling code is
  	// valid (which means that the region code cannot be ZZ and must
  	// be one of our supported region codes).
  	metadata := getMetadataForRegionOrCallingCode(
  		countryCallingCode, regionCode)
  	formattedNumber.WriteString(
  		formatNsn(nationalSignificantNumber, metadata, numberFormat))
  	maybeAppendFormattedExtension(number, metadata, numberFormat, formattedNumber)
  	prefixNumberWithCountryCallingCode(
  		countryCallingCode, numberFormat, formattedNumber)
  }
docs: // Same as Format(PhoneNumber, PhoneNumberFormat), but accepts a mutable
  // StringBuilder as a parameter to decrease object creation when invoked
  // many times.