Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update go to v1.23.5 + dependencies #68

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.24
1.6.25
2 changes: 1 addition & 1 deletion c/doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PROJECT_NAME = "NumKey"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = 1.6.24
PROJECT_NUMBER = 1.6.25

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
Expand Down
24 changes: 12 additions & 12 deletions cgo/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ run:
issues-exit-code: 1
tests: true
timeout: 5m
skip-dirs-use-default: true

output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
Expand Down Expand Up @@ -48,6 +47,7 @@ linters-settings:
- G115

issues:
exclude-dirs-use-default: true
exclude-dirs:
- .github
- .githook
Expand All @@ -61,15 +61,15 @@ issues:
linters:
enable-all: true
disable:
- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
- exhaustruct # Checks if all structure fields are initialized [fast: false, auto-fix: false]
- err113 # Go linter to check the errors handling expressions [fast: false, auto-fix: false]
- ireturn # Accept Interfaces, Return Concrete Types [fast: false, auto-fix: false]
- lll # Reports long lines [fast: true, auto-fix: false]
- mnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
- musttag # enforce field tags in (un)marshaled structs [fast: false, auto-fix: false]
- nlreturn # Accept Nil, Return Non-Nil [fast: false, auto-fix: false]
- tagliatelle # Checks the struct tags. [fast: true, auto-fix: false]
- testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
- varnamelen # checks that the length of a variable's name matches its scope [fast: false, auto-fix: false]
- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
- exhaustruct # Checks if all structure fields are initialized [fast: false, auto-fix: false]
- err113 # Go linter to check the errors handling expressions [fast: false, auto-fix: false]
- ireturn # Accept Interfaces, Return Concrete Types [fast: false, auto-fix: false]
- lll # Reports long lines [fast: true, auto-fix: false]
- mnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
- musttag # enforce field tags in (un)marshaled structs [fast: false, auto-fix: false]
- nlreturn # Accept Nil, Return Non-Nil [fast: false, auto-fix: false]
- tagliatelle # Checks the struct tags. [fast: true, auto-fix: false]
- testpackage # linter that makes you use a separate _test package [fast: true, auto-fix: false]
- varnamelen # checks that the length of a variable's name matches its scope [fast: false, auto-fix: false]
- exportloopref # deprecated
2 changes: 1 addition & 1 deletion cgo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ GOFMT=$(shell which gofmt)
GOTEST=GOPATH=$(GOPATH) $(shell which gotest)
GODOC=GOPATH=$(GOPATH) $(shell which godoc)
GOLANGCILINT=$(BINUTIL)/golangci-lint
GOLANGCILINTVERSION=v1.62.2
GOLANGCILINTVERSION=v1.63.4

# Directory containing the source code
SRCDIR=./src
Expand Down
4 changes: 2 additions & 2 deletions cgo/src/countrykey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func TestCountryKey(t *testing.T) {
func BenchmarkCountryKey(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
CountryKey("ZZ")
}
}
Expand All @@ -758,7 +758,7 @@ func TestDecodeCountryKey(t *testing.T) {
func BenchmarkDecodeCountryKey(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
DecodeCountryKey(23130)
}
}
23 changes: 20 additions & 3 deletions cgo/src/numkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package numkey
import "C"
import "unsafe"

// TNumKey contains the number components
// TNumKey contains the number components.
type TNumKey struct {
Country string `json:"country"`
Number string `json:"number"`
Expand All @@ -37,21 +37,25 @@ func castCNumKey(nk C.numkey_t) TNumKey {
func StringToNTBytesN(s string, size int) []byte {
b := make([]byte, size)
copy(b, s)

return b
}

// NumKey returns an encoded COUNTRY + NUMBER
// If the country or number are invalid this function returns 0
// NumKey returns an encoded COUNTRY + NUMBER.
// If the country or number are invalid this function returns 0.
func NumKey(country, number string) uint64 {
countrysize := len(country)
numsize := len(number)

if countrysize != 2 || numsize < 1 {
return 0
}

bcountry := StringToNTBytesN(country, countrysize+1)
bnumber := StringToNTBytesN(number, numsize+1)
pcountry := unsafe.Pointer(&bcountry[0]) // #nosec
pnumber := unsafe.Pointer(&bnumber[0]) // #nosec

return uint64(C.numkey((*C.char)(pcountry), (*C.char)(pnumber), C.size_t(numsize)))
}

Expand All @@ -60,8 +64,11 @@ func DecodeNumKey(nk uint64) TNumKey {
if nk == 0 {
return TNumKey{}
}

var data C.numkey_t

C.decode_numkey(C.uint64_t(nk), &data)

return castCNumKey(data)
}

Expand All @@ -73,15 +80,19 @@ func CompareNumKeyCountry(nka, nkb uint64) int {
// Hex provides a 16 digits hexadecimal string representation of a 64bit unsigned number.
func Hex(v uint64) string {
cstr := C.malloc(17)

defer C.free(cstr)

C.numkey_hex(C.uint64_t(v), (*C.char)(cstr))

return C.GoStringN((*C.char)(cstr), C.int(16))
}

// ParseHex parses a 16 digit HEX string and returns the 64 bit unsigned number.
func ParseHex(s string) uint64 {
b := StringToNTBytesN(s, len(s)+1)
p := unsafe.Pointer(&b[0]) // #nosec

return uint64(C.parse_numkey_hex((*C.char)(p)))
}

Expand All @@ -92,6 +103,7 @@ func PrefixKey(number string) uint64 {
numsize := len(number)
bnumber := StringToNTBytesN(number, numsize+1)
pnumber := unsafe.Pointer(&bnumber[0]) // #nosec

return uint64(C.prefixkey((*C.char)(pnumber), C.size_t(numsize)))
}

Expand All @@ -101,15 +113,20 @@ func CountryKey(country string) uint16 {
if countrysize != 2 {
return 0
}

bcountry := StringToNTBytesN(country, countrysize+1)
pcountry := unsafe.Pointer(&bcountry[0]) // #nosec

return uint16(C.countrykey((*C.char)(pcountry)))
}

// DecodeCountryKey decodes countrykey into ISO 3166 alpha-2 country code.
func DecodeCountryKey(ck uint16) string {
cstr := C.malloc(3)

defer C.free(cstr)

C.decode_countrykey(C.uint16_t(ck), (*C.char)(cstr))

return C.GoStringN((*C.char)(cstr), C.int(2))
}
10 changes: 5 additions & 5 deletions cgo/src/numkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ func TestNumKeyLong(t *testing.T) {
func BenchmarkNumKey(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
NumKey("ZZ", "601469829912013")
}
}
Expand Down Expand Up @@ -801,7 +801,7 @@ func TestDecodeNumKeyLong(t *testing.T) {
func BenchmarkDecodeNumKey(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
DecodeNumKey(0xd6a23089b8e15cdf)
}
}
Expand Down Expand Up @@ -836,7 +836,7 @@ func TestCompareNumKeyCountry(t *testing.T) {
func BenchmarkCompareNumKeyCountry(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
CompareNumKeyCountry(0xd6a23089b8e15cdf, 0xd6a2300000000000)
}
}
Expand All @@ -859,7 +859,7 @@ func TestHex(t *testing.T) {
func BenchmarkHex(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
_ = Hex(0xa852662880400000)
}
}
Expand All @@ -884,7 +884,7 @@ func BenchmarkParseHex(b *testing.B) {

b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
ParseHex(bs)
}
}
2 changes: 1 addition & 1 deletion cgo/src/prefixkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestPrefixKey(t *testing.T) {
func BenchmarkPrefixKey(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
PrefixKey("123456789012345")
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/Vonage/numkey

go 1.23

toolchain go1.23.4
toolchain go1.23.5

require (
github.com/jstemmer/go-junit-report/v2 v2.1.0
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def run(self):

setup(
name="numkey",
version="1.6.24.1",
version="1.6.25.1",
keywords=("numkey E.164 shortcode lvn did encoding"),
description="NumKey Bindings for Python",
long_description=read("../README.md"),
Expand Down
Loading