File: flag.go

package info (click to toggle)
golang-github-tv42-zbase32 0.0~git20160707.5015726-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 120 kB
  • sloc: sh: 13; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 583 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package zbase32

import "flag"

// Value implements flag parsing for zbase32 values.
type Value []byte

var _ flag.Value = (*Value)(nil)

// String returns the z-base-32 encoding of the value.
func (v *Value) String() string {
	return EncodeToString(*v)
}

// Set the value to data encoded by string.
func (v *Value) Set(s string) error {
	b, err := DecodeString(s)
	if err != nil {
		return err
	}
	*v = b
	return nil
}

var _ flag.Getter = (*Value)(nil)

// Get the data stored in the value. Returns a value of type []byte.
func (v *Value) Get() interface{} {
	return []byte(*v)
}