mirror of
https://github.com/astaxie/beego.git
synced 2024-11-16 07:20:55 +00:00
42 lines
678 B
Go
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
|
|
}
|