diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2018-10-15 18:03:30 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-10-15 18:03:30 +0100 |
commit | f1e31f7484231a7c51b57dba85abd174f043cc1e (patch) | |
tree | 16202b92256c50f9df255e9e76030dca674d089c /iana | |
parent | d17d7ed73609154a9c72e1194a4ad4842447dde8 (diff) |
Added String methods for types (#175)
Diffstat (limited to 'iana')
-rw-r--r-- | iana/archtype.go | 4 | ||||
-rw-r--r-- | iana/hwtypes.go | 8 | ||||
-rw-r--r-- | iana/statuscodes.go | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/iana/archtype.go b/iana/archtype.go index 6b2cc9e..ca21490 100644 --- a/iana/archtype.go +++ b/iana/archtype.go @@ -32,8 +32,8 @@ var ArchTypeToStringMap = map[ArchType]string{ } -// ArchTypeToString returns a mnemonic name for a given architecture type -func ArchTypeToString(a ArchType) string { +// String returns a mnemonic name for a given architecture type +func (a ArchType) String() string { if at := ArchTypeToStringMap[a]; at != "" { return at } diff --git a/iana/hwtypes.go b/iana/hwtypes.go index 7467a78..075cded 100644 --- a/iana/hwtypes.go +++ b/iana/hwtypes.go @@ -78,3 +78,11 @@ var HwTypeToString = map[HwTypeType]string{ HwTypeWiegandInterface: "Wiegand Interface", HwTypePureIP: "Pure IP", } + +func (h HwTypeType) String() string { + hwtype := HwTypeToString[h] + if hwtype == "" { + hwtype = "Invalid" + } + return hwtype +} diff --git a/iana/statuscodes.go b/iana/statuscodes.go index d3ca410..f61f99e 100644 --- a/iana/statuscodes.go +++ b/iana/statuscodes.go @@ -38,8 +38,8 @@ const ( StatusExcessiveTimeSkew StatusCode = 22 ) -// StatusCodeToString returns a mnemonic name for a given status code -func StatusCodeToString(s StatusCode) string { +// String returns a mnemonic name for a given status code +func (s StatusCode) String() string { if sc := StatusCodeToStringMap[s]; sc != "" { return sc } |