1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-26 18:34:13 +00:00
Beego/param/parsers.go
2017-04-21 15:26:41 +03:00

42 lines
678 B
Go

package param
import "strconv"
type paramParser interface {
parse(value string) (interface{}, error)
zeroValue() interface{}
}
type boolParser struct {
}
func (p boolParser) parse(value string) (interface{}, error) {
return strconv.ParseBool(value)
}
func (p boolParser) zeroValue() interface{} {
return false
}
type stringParser struct {
}
func (p stringParser) parse(value string) (interface{}, error) {
return value, nil
}
func (p stringParser) zeroValue() interface{} {
return ""
}
type intParser struct {
}
func (p intParser) parse(value string) (interface{}, error) {
return strconv.Atoi(value)
}
func (p intParser) zeroValue() interface{} {
return 0
}