initial commit / little collection for geo locations
This commit is contained in:
parent
ea4bf00fc6
commit
79958c89e6
5 changed files with 2026 additions and 0 deletions
3
go.mod
Normal file
3
go.mod
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module git.ar21.de/tom/country-geo-locations
|
||||||
|
|
||||||
|
go 1.21.5
|
1969
pkg/geoloc/data.go
Normal file
1969
pkg/geoloc/data.go
Normal file
File diff suppressed because it is too large
Load diff
10
pkg/geoloc/main.go
Normal file
10
pkg/geoloc/main.go
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package geoloc
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
func GetCountry(input string) *Country {
|
||||||
|
if c, exists := countries[strings.ToUpper(input)]; exists {
|
||||||
|
return &c
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
33
pkg/geoloc/main_test.go
Normal file
33
pkg/geoloc/main_test.go
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
package geoloc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetCountry(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
input string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want *Country
|
||||||
|
}{
|
||||||
|
{"GBR Test", args{input: "826"}, nil},
|
||||||
|
{"USA upper Test", args{input: "USA"}, nil},
|
||||||
|
{"Nothing Test", args{input: ""}, nil},
|
||||||
|
{"Åland Islands Test", args{input: "Aland Islands"}, nil},
|
||||||
|
{"Bahreïn Test", args{input: "Bahreïn"}, nil},
|
||||||
|
{"Bahreïn Test (FR)", args{input: "Bahrein"}, nil},
|
||||||
|
{"USA uppter Test", args{input: "US"}, GetCountry("US")},
|
||||||
|
{"USA lower Test", args{input: "us"}, GetCountry("US")},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := GetCountry(tt.args.input); !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("GetCountry() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
11
renovate.json
Normal file
11
renovate.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"packageRules": [
|
||||||
|
{
|
||||||
|
"matchPackagePatterns": ["*"],
|
||||||
|
"automerge": true,
|
||||||
|
"automergeType": "pr",
|
||||||
|
"platformAutomerge": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue