Mercurial > gemma
comparison pkg/models/gauge.go @ 1641:334d13e63342
Cosmetics.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 20 Dec 2018 13:19:54 +0100 |
parents | dd31be75ce6d |
children | a0982c38eac0 |
comparison
equal
deleted
inserted
replaced
1640:c0a2e1cd2284 | 1641:334d13e63342 |
---|---|
12 // * Raimund Renkert <raimund.renkert@intevation.de> | 12 // * Raimund Renkert <raimund.renkert@intevation.de> |
13 | 13 |
14 package models | 14 package models |
15 | 15 |
16 import ( | 16 import ( |
17 "errors" | |
17 "fmt" | 18 "fmt" |
18 "strconv" | 19 "strconv" |
19 "time" | 20 "time" |
20 ) | 21 ) |
21 | 22 |
41 } | 42 } |
42 | 43 |
43 // IsrsFromString converts string representation of isrs code to type Isrs | 44 // IsrsFromString converts string representation of isrs code to type Isrs |
44 func IsrsFromString(isrsCode string) (*Isrs, error) { | 45 func IsrsFromString(isrsCode string) (*Isrs, error) { |
45 if len(isrsCode) < 20 { | 46 if len(isrsCode) < 20 { |
46 return nil, fmt.Errorf("to short") | 47 return nil, errors.New("ISRS code too short") |
47 } | 48 } |
48 hm, err := strconv.Atoi(isrsCode[15:20]) | 49 hm, err := strconv.Atoi(isrsCode[15:20]) |
49 if err != nil { | 50 if err != nil { |
50 return nil, err | 51 return nil, err |
51 } | 52 } |
57 Hectometre: hm, | 58 Hectometre: hm, |
58 } | 59 } |
59 return &isrs, nil | 60 return &isrs, nil |
60 } | 61 } |
61 | 62 |
62 // ToString creates a isrs code string from Isrs | 63 // String creates a isrs code string from Isrs |
63 func (isrs *Isrs) String() string { | 64 func (isrs *Isrs) String() string { |
64 return fmt.Sprintf("%s%s%s%s%05d", | 65 return fmt.Sprintf("%s%s%s%s%05d", |
65 isrs.CountryCode, | 66 isrs.CountryCode, |
66 isrs.LoCode, | 67 isrs.LoCode, |
67 isrs.FairwaySection, | 68 isrs.FairwaySection, |