Skip to content

Commit

Permalink
phonenumberutil: update package references
Browse files Browse the repository at this point in the history
Updates #105.
  • Loading branch information
kevinburke1 committed Jun 21, 2021
1 parent e10923c commit b151811
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
46 changes: 37 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


[[constraint]]
name = "github.com/golang/protobuf"
name = "google.golang.org/protobuf"
version = "1.0.0"

[[constraint]]
Expand Down
14 changes: 7 additions & 7 deletions phonenumberutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/ttacon/builder"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

const (
Expand Down Expand Up @@ -2560,7 +2560,7 @@ func maybeExtractCountryCode(
}
potentialCountryCode := extractCountryCode(fullNumber, nationalNumber)
if potentialCountryCode != 0 {
phoneNumber.CountryCode = proto.Int(potentialCountryCode)
phoneNumber.CountryCode = proto.Int32(int32(potentialCountryCode))
return potentialCountryCode, nil
}

Expand Down Expand Up @@ -2610,13 +2610,13 @@ func maybeExtractCountryCode(
val := PhoneNumber_FROM_NUMBER_WITHOUT_PLUS_SIGN
phoneNumber.CountryCodeSource = &val
}
phoneNumber.CountryCode = proto.Int(defaultCountryCode)
phoneNumber.CountryCode = proto.Int32(int32(defaultCountryCode))
return defaultCountryCode, nil
}
}
}
// No country calling code present.
phoneNumber.CountryCode = proto.Int(0)
phoneNumber.CountryCode = proto.Int32(0)
return 0, nil
}

Expand Down Expand Up @@ -2867,7 +2867,7 @@ func setItalianLeadingZerosForPhoneNumber(
numLeadZeros++
}
if numLeadZeros != 1 {
phoneNumber.NumberOfLeadingZeros = proto.Int(numLeadZeros)
phoneNumber.NumberOfLeadingZeros = proto.Int32(int32(numLeadZeros))
}
}

Expand Down Expand Up @@ -2958,7 +2958,7 @@ func parseHelper(
normalizedNationalNumber.WriteString(normalize(nationalNumber.String()))
if len(defaultRegion) != 0 {
countryCode = int(regionMetadata.GetCountryCode())
phoneNumber.CountryCode = proto.Int(countryCode)
phoneNumber.CountryCode = proto.Int32(int32(countryCode))
} else if keepRawInput {
phoneNumber.CountryCodeSource = nil
}
Expand Down Expand Up @@ -3130,7 +3130,7 @@ func isNumberMatchWithNumbers(firstNumberIn, secondNumberIn *PhoneNumber) MatchT
// Checks cases where one or both country_code fields were not
// specified. To make equality checks easier, we first set the
// country_code fields to be equal.
firstNumber.CountryCode = proto.Int(int(secondNumberCountryCode))
firstNumber.CountryCode = proto.Int32(secondNumberCountryCode)
// If all else was the same, then this is an NSN_MATCH.
// TODO(ttacon): remove when make gen-equals
if reflect.DeepEqual(firstNumber, secondNumber) {
Expand Down
10 changes: 5 additions & 5 deletions phonenumberutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

func TestParse(t *testing.T) {
Expand Down Expand Up @@ -273,8 +273,8 @@ func Test_IsValidNumber(t *testing.T) {
continue
}
if IsValidNumber(num) != test.isValid {
t.Errorf("[test %d:validity] failed: %v != %v\n",
i, IsValidNumber(num), test.isValid)
t.Errorf("[test %d:validity] failed: IsValidNumber(%v) = %v, want %v\n",
i, num, IsValidNumber(num), test.isValid)
}
}
}
Expand Down Expand Up @@ -566,9 +566,9 @@ var testPhoneNumbers = map[string]*PhoneNumber{
"UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT": newPhoneNumber(2, 12345),
}

func newPhoneNumber(cc int, natNum uint64) *PhoneNumber {
func newPhoneNumber(cc int32, natNum uint64) *PhoneNumber {
p := &PhoneNumber{}
p.CountryCode = proto.Int(cc)
p.CountryCode = proto.Int32(cc)
p.NationalNumber = proto.Uint64(natNum)
return p
}
Expand Down

0 comments on commit b151811

Please sign in to comment.