123456789101112131415161718192021222324252627 |
- package array
- import (
- "encoding/json"
- "errors"
- "strconv"
- "strings"
- )
- type ArrayFlags map[int]string
- func (i ArrayFlags) String() string {
- text, _ := json.Marshal(i)
- return string(text)
- }
- func (i ArrayFlags) Set(value string) error {
- values := strings.Split(value, ":")
- if len(values) != 2 {
- return errors.New("Invalid location")
- }
- id, _ := strconv.ParseInt(values[0], 10, 32)
- i[int(id)] = values[1]
- return nil
- }
|