From d914b7d905c3cf58a6cd46946b69a05b7fbec317 Mon Sep 17 00:00:00 2001 From: ycc Date: Thu, 28 Oct 2021 15:12:53 +0200 Subject: [PATCH] add utility functions --- pg.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pg.go b/pg.go index 952559e..061b305 100755 --- a/pg.go +++ b/pg.go @@ -321,3 +321,20 @@ func removeLastChar(s string) string { r := []rune(s) return string(r[:len(r)-1]) } + +func (ar *AssRow) GetString(column string) string { + str := fmt.Sprintf("%v", (*ar)[column]) + return str +} + +func (ar *AssRow) GetInt(column string) int { + str := fmt.Sprintf("%v", (*ar)[column]) + val, _ := strconv.Atoi(str) + return val +} + +func (ar *AssRow) GetFloat(column string) float64 { + str := fmt.Sprintf("%v", (*ar)[column]) + val, _ := strconv.ParseFloat(str, 64) + return val +}