Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
n10v committed Oct 23, 2016
1 parent dabebe2 commit 86d3545
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 22 deletions.
2 changes: 1 addition & 1 deletion flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ func (f *FlagSet) VarPF(value Value, name, shorthand, usage string) *Flag {

// VarP is like Var, but accepts a shorthand letter that can be used after a single dash.
func (f *FlagSet) VarP(value Value, name, shorthand, usage string) {
_ = f.VarPF(value, name, shorthand, usage)
f.VarPF(value, name, shorthand, usage)
}

// AddFlag will add the flag to the FlagSet
Expand Down
8 changes: 4 additions & 4 deletions flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ func TestFlagSetParse(t *testing.T) {

func TestChangedHelper(t *testing.T) {
f := NewFlagSet("changedtest", ContinueOnError)
_ = f.Bool("changed", false, "changed bool")
_ = f.Bool("settrue", true, "true to true")
_ = f.Bool("setfalse", false, "false to false")
_ = f.Bool("unchanged", false, "unchanged bool")
f.Bool("changed", false, "changed bool")
f.Bool("settrue", true, "true to true")
f.Bool("setfalse", false, "false to false")
f.Bool("unchanged", false, "unchanged bool")

args := []string{"--changed", "--settrue", "--setfalse=false"}
if err := f.Parse(args); err != nil {
Expand Down
3 changes: 0 additions & 3 deletions golangflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ package pflag

import (
goflag "flag"
"fmt"
"reflect"
"strings"
)

var _ = fmt.Print

// flagValueWrapper implements pflag.Value around a flag.Value. The main
// difference here is the addition of the Type method that returns a string
// name of the type. As this is generally unknown, we approximate that with
Expand Down
2 changes: 0 additions & 2 deletions ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"strings"
)

var _ = strings.TrimSpace

// -- net.IP value
type ipValue net.IP

Expand Down
2 changes: 0 additions & 2 deletions ipnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ func (*ipNetValue) Type() string {
return "ipNet"
}

var _ = strings.TrimSpace

func newIPNetValue(val net.IPNet, p *net.IPNet) *ipNetValue {
*p = val
return (*ipNetValue)(p)
Expand Down
6 changes: 0 additions & 6 deletions string_array.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package pflag

import (
"fmt"
)

var _ = fmt.Fprint

// -- stringArray Value
type stringArrayValue struct {
value *[]string
Expand Down
5 changes: 1 addition & 4 deletions string_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ package pflag
import (
"bytes"
"encoding/csv"
"fmt"
"strings"
)

var _ = fmt.Fprint

// -- stringSlice Value
type stringSliceValue struct {
value *[]string
Expand Down Expand Up @@ -39,7 +36,7 @@ func writeAsCSV(vals []string) (string, error) {
return "", err
}
w.Flush()
return strings.TrimSuffix(b.String(), fmt.Sprintln()), nil
return strings.TrimSuffix(b.String(), "\n"), nil
}

func (s *stringSliceValue) Set(val string) error {
Expand Down

0 comments on commit 86d3545

Please sign in to comment.