Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 43c89b0

Browse files
chore: use any in place of interface{}
This addresses the lint raised by gopls for modernizing the usage of an empty interface for the `any` type. Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
1 parent 34f8c1b commit 43c89b0

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

‎internal/codegen/golang/go_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ func goInnerType(req *plugin.GenerateRequest, options *opts.Options, col *plugin
8787
case "sqlite":
8888
return sqliteType(req, options, col)
8989
default:
90-
return "interface{}"
90+
return "any"
9191
}
9292
}

‎internal/codegen/golang/mysql_type.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func mysqlType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.C
111111
return "json.RawMessage"
112112

113113
case "any":
114-
return "interface{}"
114+
return "any"
115115

116116
default:
117117
for _, schema := range req.Catalog.Schemas {
@@ -134,7 +134,7 @@ func mysqlType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.C
134134
if debug.Active {
135135
log.Printf("Unknown MySQL type: %s\n", columnType)
136136
}
137-
return "interface{}"
137+
return "any"
138138

139139
}
140140
}

‎internal/codegen/golang/postgresql_type.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
178178
return "pqtype.NullRawMessage"
179179
}
180180
default:
181-
return "interface{}"
181+
return "any"
182182
}
183183

184184
case "jsonb", "pg_catalog.jsonb":
@@ -194,7 +194,7 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
194194
return "pqtype.NullRawMessage"
195195
}
196196
default:
197-
return "interface{}"
197+
return "any"
198198
}
199199

200200
case "bytea", "blob", "pg_catalog.bytea":
@@ -293,7 +293,7 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
293293
case opts.SQLDriverLibPQ:
294294
return "pqtype.Inet"
295295
default:
296-
return "interface{}"
296+
return "any"
297297
}
298298

299299
case "cidr":
@@ -308,7 +308,7 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
308308
case opts.SQLDriverLibPQ:
309309
return "pqtype.CIDR"
310310
default:
311-
return "interface{}"
311+
return "any"
312312
}
313313

314314
case "macaddr", "macaddr8":
@@ -320,7 +320,7 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
320320
case opts.SQLDriverLibPQ:
321321
return "pqtype.Macaddr"
322322
default:
323-
return "interface{}"
323+
return "any"
324324
}
325325

326326
case "ltree", "lquery", "ltxtquery":
@@ -359,15 +359,15 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
359359
case opts.SQLDriverPGXV5:
360360
return "pgtype.Range[pgtype.Date]"
361361
default:
362-
return "interface{}"
362+
return "any"
363363
}
364364

365365
case "datemultirange":
366366
switch driver {
367367
case opts.SQLDriverPGXV5:
368368
return "pgtype.Multirange[pgtype.Range[pgtype.Date]]"
369369
default:
370-
return "interface{}"
370+
return "any"
371371
}
372372

373373
case "tsrange":
@@ -377,15 +377,15 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
377377
case opts.SQLDriverPGXV5:
378378
return "pgtype.Range[pgtype.Timestamp]"
379379
default:
380-
return "interface{}"
380+
return "any"
381381
}
382382

383383
case "tsmultirange":
384384
switch driver {
385385
case opts.SQLDriverPGXV5:
386386
return "pgtype.Multirange[pgtype.Range[pgtype.Timestamp]]"
387387
default:
388-
return "interface{}"
388+
return "any"
389389
}
390390

391391
case "tstzrange":
@@ -395,15 +395,15 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
395395
case opts.SQLDriverPGXV5:
396396
return "pgtype.Range[pgtype.Timestamptz]"
397397
default:
398-
return "interface{}"
398+
return "any"
399399
}
400400

401401
case "tstzmultirange":
402402
switch driver {
403403
case opts.SQLDriverPGXV5:
404404
return "pgtype.Multirange[pgtype.Range[pgtype.Timestamptz]]"
405405
default:
406-
return "interface{}"
406+
return "any"
407407
}
408408

409409
case "numrange":
@@ -413,15 +413,15 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
413413
case opts.SQLDriverPGXV5:
414414
return "pgtype.Range[pgtype.Numeric]"
415415
default:
416-
return "interface{}"
416+
return "any"
417417
}
418418

419419
case "nummultirange":
420420
switch driver {
421421
case opts.SQLDriverPGXV5:
422422
return "pgtype.Multirange[pgtype.Range[pgtype.Numeric]]"
423423
default:
424-
return "interface{}"
424+
return "any"
425425
}
426426

427427
case "int4range":
@@ -431,15 +431,15 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
431431
case opts.SQLDriverPGXV5:
432432
return "pgtype.Range[pgtype.Int4]"
433433
default:
434-
return "interface{}"
434+
return "any"
435435
}
436436

437437
case "int4multirange":
438438
switch driver {
439439
case opts.SQLDriverPGXV5:
440440
return "pgtype.Multirange[pgtype.Range[pgtype.Int4]]"
441441
default:
442-
return "interface{}"
442+
return "any"
443443
}
444444

445445
case "int8range":
@@ -449,22 +449,22 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
449449
case opts.SQLDriverPGXV5:
450450
return "pgtype.Range[pgtype.Int8]"
451451
default:
452-
return "interface{}"
452+
return "any"
453453
}
454454

455455
case "int8multirange":
456456
switch driver {
457457
case opts.SQLDriverPGXV5:
458458
return "pgtype.Multirange[pgtype.Range[pgtype.Int8]]"
459459
default:
460-
return "interface{}"
460+
return "any"
461461
}
462462

463463
case "hstore":
464464
if driver.IsPGX() {
465465
return "pgtype.Hstore"
466466
}
467-
return "interface{}"
467+
return "any"
468468

469469
case "bit", "varbit", "pg_catalog.bit", "pg_catalog.varbit":
470470
if driver == opts.SQLDriverPGXV5 {
@@ -549,16 +549,16 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
549549

550550
case "void":
551551
// A void value can only be scanned into an empty interface.
552-
return "interface{}"
552+
return "any"
553553

554554
case "any":
555-
return "interface{}"
555+
return "any"
556556

557557
default:
558558
rel, err := parseIdentifierString(columnType)
559559
if err != nil {
560560
// TODO: Should this actually return an error here?
561-
return "interface{}"
561+
return "any"
562562
}
563563
if rel.Schema == "" {
564564
rel.Schema = req.Catalog.DefaultSchema
@@ -602,5 +602,5 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
602602
if debug.Active {
603603
log.Printf("unknown PostgreSQL type: %s\n", columnType)
604604
}
605-
return "interface{}"
605+
return "any"
606606
}

‎internal/codegen/golang/sqlite_type.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func sqliteType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.
5757
return "sql.NullTime"
5858

5959
case "any":
60-
return "interface{}"
60+
return "any"
6161

6262
}
6363

@@ -93,7 +93,7 @@ func sqliteType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.
9393
log.Printf("unknown SQLite type: %s\n", dt)
9494
}
9595

96-
return "interface{}"
96+
return "any"
9797

9898
}
9999
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /