Skip to content

Commit e884147

Browse files
author
Peter Steinberger
committed
chore(lint): dedupe file string
1 parent cfaee0b commit e884147

8 files changed

Lines changed: 18 additions & 13 deletions

File tree

internal/cmd/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func ensureKeychainAccessIfNeeded() error {
3232
if err != nil {
3333
return fmt.Errorf("resolve keyring backend: %w", err)
3434
}
35-
if backendInfo.Value == "file" {
35+
if backendInfo.Value == strFile {
3636
return nil
3737
}
3838
return ensureKeychainAccess()

internal/cmd/auth_keyring.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (c *AuthKeyringCmd) Run(ctx context.Context) error {
6969
allowed := map[string]struct{}{
7070
"auto": {},
7171
"keychain": {},
72-
"file": {},
72+
strFile: {},
7373
}
7474
if _, ok := allowed[backend]; !ok {
7575
return usagef("invalid backend: %q (expected auto, keychain, or file)", c.Backend)
@@ -94,7 +94,7 @@ func (c *AuthKeyringCmd) Run(ctx context.Context) error {
9494
u.Err().Printf("NOTE: GOG_KEYRING_BACKEND=%s overrides config.json", v)
9595
}
9696

97-
if backend == "file" &&
97+
if backend == strFile &&
9898
u != nil &&
9999
!outfmt.IsJSON(ctx) &&
100100
!outfmt.IsPlain(ctx) {

internal/cmd/docs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (c *DocsInfoCmd) Run(ctx context.Context, flags *RootFlags) error {
9090

9191
if outfmt.IsJSON(ctx) {
9292
return outfmt.WriteJSON(os.Stdout, map[string]any{
93-
"file": file,
93+
strFile: file,
9494
"document": doc,
9595
})
9696
}
@@ -151,7 +151,7 @@ func (c *DocsCreateCmd) Run(ctx context.Context, flags *RootFlags) error {
151151
}
152152

153153
if outfmt.IsJSON(ctx) {
154-
return outfmt.WriteJSON(os.Stdout, map[string]any{"file": created})
154+
return outfmt.WriteJSON(os.Stdout, map[string]any{strFile: created})
155155
}
156156

157157
u.Out().Printf("id\t%s", created.Id)

internal/cmd/drive.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (c *DriveGetCmd) Run(ctx context.Context, flags *RootFlags) error {
226226
}
227227

228228
if outfmt.IsJSON(ctx) {
229-
return outfmt.WriteJSON(os.Stdout, map[string]any{"file": f})
229+
return outfmt.WriteJSON(os.Stdout, map[string]any{strFile: f})
230230
}
231231

232232
u.Out().Printf("id\t%s", f.Id)
@@ -370,7 +370,7 @@ func (c *DriveUploadCmd) Run(ctx context.Context, flags *RootFlags) error {
370370
}
371371

372372
if outfmt.IsJSON(ctx) {
373-
return outfmt.WriteJSON(os.Stdout, map[string]any{"file": created})
373+
return outfmt.WriteJSON(os.Stdout, map[string]any{strFile: created})
374374
}
375375

376376
u.Out().Printf("id\t%s", created.Id)
@@ -518,7 +518,7 @@ func (c *DriveMoveCmd) Run(ctx context.Context, flags *RootFlags) error {
518518
}
519519

520520
if outfmt.IsJSON(ctx) {
521-
return outfmt.WriteJSON(os.Stdout, map[string]any{"file": updated})
521+
return outfmt.WriteJSON(os.Stdout, map[string]any{strFile: updated})
522522
}
523523

524524
u.Out().Printf("id\t%s", updated.Id)
@@ -561,7 +561,7 @@ func (c *DriveRenameCmd) Run(ctx context.Context, flags *RootFlags) error {
561561
}
562562

563563
if outfmt.IsJSON(ctx) {
564-
return outfmt.WriteJSON(os.Stdout, map[string]any{"file": updated})
564+
return outfmt.WriteJSON(os.Stdout, map[string]any{strFile: updated})
565565
}
566566

567567
u.Out().Printf("id\t%s", updated.Id)
@@ -823,7 +823,7 @@ func driveType(mimeType string) string {
823823
if mimeType == "application/vnd.google-apps.folder" {
824824
return "folder"
825825
}
826-
return "file" //nolint:goconst // readability; used as a display value and JSON key elsewhere.
826+
return strFile
827827
}
828828

829829
func formatDateTime(iso string) string {

internal/cmd/drive_copy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func copyViaDrive(ctx context.Context, flags *RootFlags, opts copyViaDriveOption
8282
}
8383

8484
if outfmt.IsJSON(ctx) {
85-
return outfmt.WriteJSON(os.Stdout, map[string]any{"file": created})
85+
return outfmt.WriteJSON(os.Stdout, map[string]any{strFile: created})
8686
}
8787
u.Out().Printf("id\t%s", created.Id)
8888
u.Out().Printf("name\t%s", created.Name)

internal/cmd/info_via_drive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func infoViaDrive(ctx context.Context, flags *RootFlags, opts infoViaDriveOption
6060
}
6161

6262
if outfmt.IsJSON(ctx) {
63-
return outfmt.WriteJSON(os.Stdout, map[string]any{"file": f})
63+
return outfmt.WriteJSON(os.Stdout, map[string]any{strFile: f})
6464
}
6565

6666
u.Out().Printf("id\t%s", f.Id)

internal/cmd/slides.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (c *SlidesCreateCmd) Run(ctx context.Context, flags *RootFlags) error {
9090
}
9191

9292
if outfmt.IsJSON(ctx) {
93-
return outfmt.WriteJSON(os.Stdout, map[string]any{"file": created})
93+
return outfmt.WriteJSON(os.Stdout, map[string]any{strFile: created})
9494
}
9595

9696
u.Out().Printf("id\t%s", created.Id)

internal/cmd/strings.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package cmd
2+
3+
const (
4+
strFile = "file"
5+
)

0 commit comments

Comments
 (0)