add utility functions

This commit is contained in:
ycc 2021-10-28 15:12:53 +02:00
parent b16fa31515
commit d914b7d905

17
pg.go
View File

@ -321,3 +321,20 @@ func removeLastChar(s string) string {
r := []rune(s) r := []rune(s)
return string(r[:len(r)-1]) 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
}