diff options
| author | Patrick Spek <p.spek@tyil.nl> | 2024-11-28 07:29:26 +0100 |
|---|---|---|
| committer | Patrick Spek <p.spek@tyil.nl> | 2024-11-28 07:29:26 +0100 |
| commit | 1b82df08f0e186fe5968543d69babbea6703646a (patch) | |
| tree | a2352a8727b97f0364974f9e2feaab5dfdcb3c5a | |
| parent | bf776fc41bf4418ddd37af5aa0452b0a06cd3672 (diff) | |
| download | fsdir-1b82df08f0e186fe5968543d69babbea6703646a.tar.gz fsdir-1b82df08f0e186fe5968543d69babbea6703646a.tar.bz2 | |
Make flags lib prettier
| -rw-r--r-- | flags.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -6,6 +6,7 @@ import ( ) type MapVar map[string]string +type SliceVar []string func (this *MapVar) Set(value string) error { if *this == nil { @@ -20,21 +21,21 @@ func (this *MapVar) Set(value string) error { } func (this *MapVar) String() string { - s := "" + slice := []string{} for key, value := range *this { - s += fmt.Sprintf("%s: %v\n", key, value) + slice = append(slice, fmt.Sprintf("%s: %v,", key, value)) } - return fmt.Sprintf("{%s}", s) + return fmt.Sprintf("{%s}", strings.Join(slice, ",")) } -type SliceVar []string - func (this *SliceVar) Set(value string) error { + *this = append(*this, value) + return nil } func (this *SliceVar) String() string { - return "" + return fmt.Sprintf("[%s]", strings.Join(*this, ",")) } |
