Skip to content

Commit

Permalink
Excavator: Manage go version (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot authored Sep 10, 2024
1 parent 0b09eae commit 5dcef27
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .palantir/go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
go1.22.6
go1.23.1
57 changes: 57 additions & 0 deletions generated_src/internal/amalgomated_flag/example_flagset_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package flag_test

import (
"flag"
"fmt"
"time"
)

func ExampleFlagSet() {

start := func(args []string) {
// A real program (not an example) would use flag.ExitOnError.
fs := flag.NewFlagSet("start", flag.ContinueOnError)
addr := fs.String("addr", ":8080", "`address` to listen on")
if err := fs.Parse(args); err != nil {
fmt.Printf("error: %s", err)
return
}
fmt.Printf("starting server on %s\n", *addr)
}

stop := func(args []string) {
fs := flag.NewFlagSet("stop", flag.ContinueOnError)
timeout := fs.Duration("timeout", time.Second, "stop timeout duration")
if err := fs.Parse(args); err != nil {
fmt.Printf("error: %s", err)
return
}
fmt.Printf("stopping server (timeout=%v)\n", *timeout)
}

main := func(args []string) {
subArgs := args[2:] // Drop program name and command.
switch args[1] {
case "start":
start(subArgs)
case "stop":
stop(subArgs)
default:
fmt.Printf("error: unknown command - %q\n", args[1])
// In a real program (not an example) print to os.Stderr and exit the program with non-zero value.
}
}

main([]string{"httpd", "start", "-addr", ":9999"})
main([]string{"httpd", "stop"})
main([]string{"http", "start", "-log-level", "verbose"})

// Output:
// starting server on :9999
// stopping server (timeout=1s)
// error: flag provided but not defined: -log-level
}
6 changes: 3 additions & 3 deletions generated_src/internal/amalgomated_flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import (
"os"
"reflect"
"runtime"
"sort"
"slices"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -420,8 +420,8 @@ func sortFlags(flags map[string]*Flag) []*Flag {
result[i] = f
i++
}
sort.Slice(result, func(i, j int) bool {
return result[i].Name < result[j].Name
slices.SortFunc(result, func(a, b *Flag) int {
return strings.Compare(a.Name, b.Name)
})
return result
}
Expand Down
4 changes: 2 additions & 2 deletions generated_src/internal/amalgomated_flag/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"os/exec"
"regexp"
"runtime"
"sort"
"slices"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestEverything(t *testing.T) {
// Now test they're visited in sort order.
var flagNames []string
Visit(func(f *Flag) { flagNames = append(flagNames, f.Name) })
if !sort.StringsAreSorted(flagNames) {
if !slices.IsSorted(flagNames) {
t.Errorf("flag names not sorted: %v", flagNames)
}
}
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-golint

go 1.22.0
go 1.23.0

require (
github.com/nmiyake/pkg/gofiles v1.2.0
Expand Down

0 comments on commit 5dcef27

Please sign in to comment.