Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
invinoveritas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
gbe
invinoveritas
Commits
9b447fdc
Commit
9b447fdc
authored
3 years ago
by
gbe
Browse files
Options
Downloads
Patches
Plain Diff
Clean up handling and loading of ISO2 country codes
parent
3638474e
No related branches found
No related tags found
No related merge requests found
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
handler-details.go
+1
-1
1 addition, 1 deletion
handler-details.go
vino.go
+6
-2
6 additions, 2 deletions
vino.go
with
7 additions
and
3 deletions
handler-details.go
+
1
−
1
View file @
9b447fdc
...
...
@@ -98,7 +98,7 @@ func (h Handler) detailsPost(w http.ResponseWriter, r *http.Request) {
return
}
country
,
err
:=
ISO
3
CountryFromString
(
r
.
FormValue
(
"country"
))
country
,
err
:=
ISO
2
Country
Code
FromString
(
r
.
FormValue
(
"country"
))
if
err
!=
nil
{
httpError
(
w
,
"can't parse country"
,
nil
,
http
.
StatusBadRequest
)
return
...
...
This diff is collapsed.
Click to expand it.
vino.go
+
6
−
2
View file @
9b447fdc
...
...
@@ -32,7 +32,7 @@ type ISO2CountryCode [2]byte
var
UnknownCountry
=
ISO2CountryCode
{
'X'
,
'X'
}
func
ISO
3
CountryFromString
(
s
string
)
(
ISO2CountryCode
,
error
)
{
func
ISO
2
Country
Code
FromString
(
s
string
)
(
ISO2CountryCode
,
error
)
{
if
len
(
s
)
==
0
{
return
UnknownCountry
,
nil
}
...
...
@@ -45,6 +45,10 @@ func ISO3CountryFromString(s string) (ISO2CountryCode, error) {
}
func
(
i
ISO2CountryCode
)
String
()
string
{
if
i
[
0
]
==
0
||
i
[
1
]
==
0
{
return
"XX"
}
return
fmt
.
Sprintf
(
"%c%c"
,
i
[
0
],
i
[
1
])
}
...
...
@@ -59,7 +63,7 @@ func (i *ISO2CountryCode) UnmarshalBinary(d []byte) error {
return
nil
}
*
i
=
ISO2CountryCode
{
d
[
0
],
d
[
1
]}
copy
(
i
[
:
],
d
)
return
nil
}
...
...
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