summaryrefslogtreecommitdiff
path: root/sanitize_price.go
diff options
context:
space:
mode:
authorhorus_arch2018-02-04 20:54:58 +0100
committerhorus_arch2018-02-04 20:54:58 +0100
commit4f7a9316da8e19fa9466ee377148c7d07bf39fd9 (patch)
tree7c4fb5b35ea107d7379b4c7a601aa9a7d9d184d5 /sanitize_price.go
parentfe12a1d41d74ac55dc3c1b27821375541ee5f2b2 (diff)
downloadalkobote-4f7a9316da8e19fa9466ee377148c7d07bf39fd9.tar.gz
Data from all shops are now saved in a data structure.
Diffstat (limited to 'sanitize_price.go')
-rw-r--r--sanitize_price.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/sanitize_price.go b/sanitize_price.go
index 8b9443f..2052842 100644
--- a/sanitize_price.go
+++ b/sanitize_price.go
@@ -7,6 +7,10 @@ import (
)
func sanitize_price(price string) (int, error) {
+ if "" == price {
+ return 0, errors.New("Empty string")
+ }
+
multiply_by_10 := false
multiply_by_100 := true
@@ -24,6 +28,12 @@ func sanitize_price(price string) (int, error) {
price = strings.TrimSuffix(strings.ToLower(price), "euro")
price = strings.TrimSpace(price)
+ if len(price) < 2 {
+ price = "0" + price
+ } else if len(price) < 3 {
+ price = "00" + price
+ }
+
c := string(price[len(price)-2:])
c = string(c[0:1])