Skip to content

Commit 9e7677a

Browse files
committed
run modernize -fix
- replace interface{} with any - use min / max functions - use fmt.Appendf for byte[] slice creation with strings - use slices package
1 parent 08d669c commit 9e7677a

File tree

89 files changed

+219
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+219
-255
lines changed

cmd/src/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Examples:
7676
}
7777

7878
// Determine which variables to use in the request.
79-
vars := map[string]interface{}{}
79+
vars := map[string]any{}
8080
if *varsFlag != "" {
8181
if err := json.Unmarshal([]byte(*varsFlag), &vars); err != nil {
8282
return err
@@ -93,7 +93,7 @@ Examples:
9393
}
9494

9595
// Perform the request.
96-
var result interface{}
96+
var result any
9797
if ok, err := cfg.apiClient(apiFlags, flagSet.Output()).NewRequest(query, vars).DoRaw(context.Background(), &result); err != nil || !ok {
9898
return err
9999
}

cmd/src/cmd.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log"
77
"os"
8+
"slices"
89

910
"github.com/sourcegraph/src-cli/internal/cmderrors"
1011
)
@@ -30,12 +31,7 @@ func (c *command) matches(name string) bool {
3031
if name == c.flagSet.Name() {
3132
return true
3233
}
33-
for _, alias := range c.aliases {
34-
if name == alias {
35-
return true
36-
}
37-
}
38-
return false
34+
return slices.Contains(c.aliases, name)
3935
}
4036

4137
// commander represents a top-level command with subcommands.
@@ -60,7 +56,6 @@ func (c commander) run(flagSet *flag.FlagSet, cmdName, usageText string, args []
6056

6157
// Configure default usage funcs for commands.
6258
for _, cmd := range c {
63-
cmd := cmd
6459
if cmd.usageFunc != nil {
6560
cmd.flagSet.Usage = cmd.usageFunc
6661
continue

cmd/src/code_intel_upload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func handleCodeIntelUpload(args []string) error {
9898
}
9999

100100
if codeintelUploadFlags.json {
101-
serialized, err := json.Marshal(map[string]interface{}{
101+
serialized, err := json.Marshal(map[string]any{
102102
"repo": codeintelUploadFlags.repo,
103103
"commit": codeintelUploadFlags.commit,
104104
"root": codeintelUploadFlags.root,
@@ -202,7 +202,7 @@ func makeCodeIntelUploadURL(uploadID int) (string, error) {
202202
return "", err
203203
}
204204

205-
graphqlID := base64.URLEncoding.EncodeToString([]byte(fmt.Sprintf(`SCIPUpload:%d`, uploadID)))
205+
graphqlID := base64.URLEncoding.EncodeToString(fmt.Appendf(nil, `SCIPUpload:%d`, uploadID))
206206
url.Path = codeintelUploadFlags.repo + "/-/code-intelligence/uploads/" + graphqlID
207207
url.User = nil
208208
return url.String(), nil

cmd/src/codeowners_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Examples:
8888
var result struct {
8989
AddCodeownersFile CodeownersIngestedFile
9090
}
91-
if ok, err := client.NewRequest(query, map[string]interface{}{
91+
if ok, err := client.NewRequest(query, map[string]any{
9292
"repoName": *repoFlag,
9393
"content": string(content),
9494
}).Do(context.Background(), &result); err != nil || !ok {

cmd/src/codeowners_delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Examples:
5757
var result struct {
5858
DeleteCodeownersFile CodeownersIngestedFile
5959
}
60-
if ok, err := client.NewRequest(query, map[string]interface{}{
60+
if ok, err := client.NewRequest(query, map[string]any{
6161
"repoName": *repoFlag,
6262
}).Do(context.Background(), &result); err != nil || !ok {
6363
var gqlErr api.GraphQlErrors

cmd/src/codeowners_get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Examples:
5959
IngestedCodeowners *CodeownersIngestedFile
6060
}
6161
}
62-
if ok, err := client.NewRequest(query, map[string]interface{}{
62+
if ok, err := client.NewRequest(query, map[string]any{
6363
"repoName": *repoFlag,
6464
}).Do(context.Background(), &result); err != nil || !ok {
6565
return err

cmd/src/codeowners_update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Examples:
8686
var result struct {
8787
UpdateCodeownersFile CodeownersIngestedFile
8888
}
89-
if ok, err := client.NewRequest(query, map[string]interface{}{
89+
if ok, err := client.NewRequest(query, map[string]any{
9090
"repoName": *repoFlag,
9191
"content": string(content),
9292
}).Do(context.Background(), &result); err != nil || !ok {

cmd/src/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ query SettingsSubjectLatestSettingsID($subject: ID!) {
159159
}
160160
}
161161

162-
if _, err := client.NewRequest(query, map[string]interface{}{
162+
if _, err := client.NewRequest(query, map[string]any{
163163
"subject": subjectID,
164164
}).Do(ctx, &result); err != nil {
165165
return nil, err

cmd/src/config_edit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ mutation EditSettings($input: SettingsMutationGroupInput!, $edit: SettingsEdit!)
109109
}
110110
}
111111
}`
112-
queryVars := map[string]interface{}{
113-
"input": map[string]interface{}{
112+
queryVars := map[string]any{
113+
"input": map[string]any{
114114
"subject": subjectID,
115115
"lastID": lastID,
116116
},
117-
"edit": map[string]interface{}{
117+
"edit": map[string]any{
118118
"keyPath": keyPath,
119119
"value": value,
120120
"valueIsJSONCEncodedString": true,

cmd/src/config_get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ Examples:
5050
}
5151

5252
var query string
53-
var queryVars map[string]interface{}
53+
var queryVars map[string]any
5454
if *subjectFlag == "" {
5555
query = viewerSettingsQuery
5656
} else {
5757
query = settingsSubjectCascadeQuery
58-
queryVars = map[string]interface{}{
58+
queryVars = map[string]any{
5959
"subject": api.NullString(*subjectFlag),
6060
}
6161
}

0 commit comments

Comments
 (0)