Skip to content

Commit

Permalink
Excavator: Manage go version (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot authored Feb 9, 2023
1 parent e2622e5 commit 5ae5d69
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .palantir/go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
go1.19.4
go1.20
6 changes: 4 additions & 2 deletions generated_src/internal/amalgomated_flag/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func Example() {
// to enable the flag package to see the flags defined there, one must
// execute, typically at the start of main (not init!):
// flag.Parse()
// We don't run it here because this is not a main function and
// the testing suite has already parsed the flags.
// We don't call it here because this code is a function called "Example"
// that is part of the testing suite for the package, which has already
// parsed the flags. When viewed at pkg.go.dev, however, the function is
// renamed to "main" and it could be run as a standalone example.
}
12 changes: 7 additions & 5 deletions generated_src/internal/amalgomated_flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,11 @@ func UnquoteUsage(flag *Flag) (name string, usage string) {
}
// No explicit name, so use type if we can find one.
name = "value"
switch flag.Value.(type) {
switch fv := flag.Value.(type) {
case boolFlag:
name = ""
if fv.IsBoolFlag() {
name = ""
}
case *durationValue:
name = "duration"
case *float64Value:
Expand Down Expand Up @@ -1054,9 +1056,9 @@ func (f *FlagSet) parseOne() (bool, error) {
break
}
}
m := f.formal
flag, alreadythere := m[name] // BUG
if !alreadythere {

flag, ok := f.formal[name]
if !ok {
if name == "help" || name == "h" { // special case for nice help message.
f.usage()
return false, ErrHelp
Expand Down
35 changes: 30 additions & 5 deletions generated_src/internal/amalgomated_flag/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,35 @@ func TestUserDefinedBool(t *testing.T) {
}
}

func TestSetOutput(t *testing.T) {
func TestUserDefinedBoolUsage(t *testing.T) {
var flags FlagSet
flags.Init("test", ContinueOnError)
var buf bytes.Buffer
flags.SetOutput(&buf)
var b boolFlagVar
flags.Var(&b, "b", "X")
b.count = 0
// b.IsBoolFlag() will return true and usage will look boolean.
flags.PrintDefaults()
got := buf.String()
want := " -b\tX\n"
if got != want {
t.Errorf("false: want %q; got %q", want, got)
}
b.count = 4
// b.IsBoolFlag() will return false and usage will look non-boolean.
flags.PrintDefaults()
got = buf.String()
want = " -b\tX\n -b value\n \tX\n"
if got != want {
t.Errorf("false: want %q; got %q", want, got)
}
}

func TestSetOutput(t *testing.T) {
var flags FlagSet
var buf strings.Builder
flags.SetOutput(&buf)
flags.Init("test", ContinueOnError)
flags.Parse([]string{"-unknown"})
if out := buf.String(); !strings.Contains(out, "-unknown") {
Expand Down Expand Up @@ -488,7 +513,7 @@ panic calling String method on zero flag_test.zeroPanicker for flag ZP1: panic!

func TestPrintDefaults(t *testing.T) {
fs := NewFlagSet("print defaults test", ContinueOnError)
var buf bytes.Buffer
var buf strings.Builder
fs.SetOutput(&buf)
fs.Bool("A", false, "for bootstrapping, allow 'any' type")
fs.Bool("Alongflagname", false, "disable bounds checking")
Expand Down Expand Up @@ -531,7 +556,7 @@ func TestIntFlagOverflow(t *testing.T) {
// Issue 20998: Usage should respect CommandLine.output.
func TestUsageOutput(t *testing.T) {
ResetForTesting(DefaultUsage)
var buf bytes.Buffer
var buf strings.Builder
CommandLine.SetOutput(&buf)
defer func(old []string) { os.Args = old }(os.Args)
os.Args = []string{"app", "-i=1", "-unknown"}
Expand Down Expand Up @@ -726,7 +751,7 @@ func TestInvalidFlags(t *testing.T) {
testName := fmt.Sprintf("FlagSet.Var(&v, %q, \"\")", test.flag)

fs := NewFlagSet("", ContinueOnError)
buf := bytes.NewBuffer(nil)
buf := &strings.Builder{}
fs.SetOutput(buf)

mustPanic(t, testName, test.errorMsg, func() {
Expand Down Expand Up @@ -758,7 +783,7 @@ func TestRedefinedFlags(t *testing.T) {
testName := fmt.Sprintf("flag redefined in FlagSet(%q)", test.flagSetName)

fs := NewFlagSet(test.flagSetName, ContinueOnError)
buf := bytes.NewBuffer(nil)
buf := &strings.Builder{}
fs.SetOutput(buf)

var v flagVar
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/palantir/godel-okgo-asset-ineffassign

go 1.19
go 1.20

require (
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8
Expand Down

0 comments on commit 5ae5d69

Please sign in to comment.