Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
b0ce0912
Commit
b0ce0912
authored
3 years ago
by
Francé Wilke
Browse files
Options
Downloads
Patches
Plain Diff
Add shared `CleanZone` to map zone name/codes
parent
c88ad68f
Branches
Branches containing commit
Tags
v1.4.3
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
address_utils/address_utils.go
+67
-0
67 additions, 0 deletions
address_utils/address_utils.go
with
67 additions
and
0 deletions
address_utils/address_utils.go
+
67
−
0
View file @
b0ce0912
...
...
@@ -72,3 +72,70 @@ func stripUnwantedCharacters(s string) string {
return
s
}
func
CleanZone
(
oldCountry
,
oldZone
*
string
)
(
newCountry
,
newZone
*
string
)
{
// Google zones
/*
"long_name": "KwaZulu-Natal",
"short_name": "KZN",
"long_name": "Gauteng",
"short_name": "GP",
"long_name": "Free State",
"short_name": "FS",
"long_name": "Limpopo",
"short_name": "LP",
"long_name": "Mpumalanga",
"short_name": "MP",
"long_name": "North West",
"short_name": "NW",
"long_name": "Western Cape",
"short_name": "WC",
"long_name": "Eastern Cape",
"short_name": "EC",
"long_name": "Northern Cape",
"short_name": "NC",
*/
newCountry
=
oldCountry
if
oldCountry
==
nil
||
*
oldCountry
==
"South Africa"
||
len
(
*
oldCountry
)
==
0
{
defaultCountry
:=
"ZA"
newCountry
=
&
defaultCountry
}
if
*
newCountry
==
"ZA"
&&
oldZone
!=
nil
{
zone
:=
*
oldZone
// Gauteng - GT from uAfrica should be GP for Google
if
zone
==
"GT"
{
zone
=
"GP"
}
else
if
zone
==
"NT"
{
zone
=
"KZN"
}
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"KwaZulu-Natal"
,
"KZN"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"KwaZulu Natal"
,
"KZN"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Gauteng"
,
"GP"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Freestate"
,
"FS"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Free State"
,
"FS"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Limpopo"
,
"LP"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Mpumalanga"
,
"MP"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"North West"
,
"NW"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Eastern Cape"
,
"EC"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Western Cape"
,
"WC"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Northern Cape"
,
"NC"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Eastern-Cape"
,
"EC"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Western-Cape"
,
"WC"
)
zone
=
string_utils
.
ReplaceCaseInsensitive
(
zone
,
"Northern-Cape"
,
"NC"
)
newZone
=
&
zone
}
return
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment