You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
569 B
45 lines
569 B
4 years ago
|
package value
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
|
||
|
"gitoa.ru/go-4devs/console/input"
|
||
|
)
|
||
|
|
||
|
type Int64 struct {
|
||
|
Empty
|
||
|
Val []int64
|
||
|
Flag input.Flag
|
||
|
}
|
||
|
|
||
|
func (i *Int64) Int64() int64 {
|
||
|
if !i.Flag.IsArray() && len(i.Val) == 1 {
|
||
|
return i.Val[0]
|
||
|
}
|
||
|
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
func (i *Int64) Int64s() []int64 {
|
||
|
return i.Val
|
||
|
}
|
||
|
|
||
|
func (i *Int64) Any() interface{} {
|
||
|
if i.Flag&input.ValueArray > 0 {
|
||
|
return i.Int64s()
|
||
|
}
|
||
|
|
||
|
return i.Int64()
|
||
|
}
|
||
|
|
||
|
func (i *Int64) Append(in string) error {
|
||
|
v, err := strconv.ParseInt(in, 10, 64)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
i.Val = append(i.Val, v)
|
||
|
|
||
|
return nil
|
||
|
}
|