MCPcopy
hub / github.com/sqlc-dev/sqlc / dbImports

Method dbImports

internal/codegen/golang/imports.go:121–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119}
120
121func (i *importer) dbImports() fileImports {
122 var pkg []ImportSpec
123 std := []ImportSpec{
124 {Path: "context"},
125 }
126
127 sqlpkg := parseDriver(i.Options.SqlPackage)
128 switch sqlpkg {
129 case opts.SQLDriverPGXV4:
130 pkg = append(pkg, ImportSpec{Path: "github.com/jackc/pgconn"})
131 pkg = append(pkg, ImportSpec{Path: "github.com/jackc/pgx/v4"})
132 case opts.SQLDriverPGXV5:
133 pkg = append(pkg, ImportSpec{Path: "github.com/jackc/pgx/v5/pgconn"})
134 pkg = append(pkg, ImportSpec{Path: "github.com/jackc/pgx/v5"})
135 default:
136 std = append(std, ImportSpec{Path: "database/sql"})
137 if i.Options.EmitPreparedQueries {
138 std = append(std, ImportSpec{Path: "fmt"})
139 }
140 }
141
142 sort.Slice(std, func(i, j int) bool { return std[i].Path < std[j].Path })
143 sort.Slice(pkg, func(i, j int) bool { return pkg[i].Path < pkg[j].Path })
144 return fileImports{Std: std, Dep: pkg}
145}
146
147var stdlibTypes = map[string]string{
148 "json.RawMessage": "encoding/json",

Callers 1

ImportsMethod · 0.95

Calls 1

parseDriverFunction · 0.85

Tested by

no test coverage detected