Format runs the respective format function on the provided parameters.
(p *FormatParams)
| 24 | |
| 25 | // Format runs the respective format function on the provided parameters. |
| 26 | func Format(p *FormatParams) (val interface{}, err error) { |
| 27 | switch strings.ToUpper(p.Name) { |
| 28 | case "FORMAT": |
| 29 | val, err = p.format() |
| 30 | case "UPPER": |
| 31 | val = upper(p.Value.(string)) |
| 32 | case "LOWER": |
| 33 | val = lower(p.Value.(string)) |
| 34 | case "FULLPATH": |
| 35 | val, err = p.fullPath() |
| 36 | case "SHORTPATH": |
| 37 | val, err = p.shortPath() |
| 38 | case "SHA1": |
| 39 | val, err = p.hash(FindHash(p.Name)()) |
| 40 | } |
| 41 | if err != nil { |
| 42 | return nil, err |
| 43 | } |
| 44 | if val == nil { |
| 45 | return nil, &ErrNotImplemented{p.Name, p.Attribute} |
| 46 | } |
| 47 | return val, nil |
| 48 | } |
| 49 | |
| 50 | // format runs a format function based on the value of the provided attribute. |
| 51 | func (p *FormatParams) format() (val interface{}, err error) { |