Source File
driver.go
Belonging Package
golang.org/x/pkgsite/internal/database
package database
import (
)
, := sql.Open(, "")
if != nil {
return "",
}
:= .Driver()
if := .Close(); != nil {
return "",
}
:= "ocWrapper-" +
sql.Register(, &wrapOCDriver{, })
return , nil
}
type wrapOCDriver struct {
underlying driver.Driver
opts []ocsql.TraceOption
}
func ( *wrapOCDriver) ( string) (driver.Conn, error) {
, := .underlying.Open()
if != nil {
return nil,
}
:= ocsql.WrapConn(, .opts...)
return &wrapConn{, .(iconn)}, nil
}
type iconn interface {
driver.Pinger
driver.ExecerContext
driver.QueryerContext
driver.Conn
driver.ConnPrepareContext
driver.ConnBeginTx
}
func ( *wrapConn) ( context.Context) error { return .oc.Ping() }
func ( *wrapConn) ( string) (driver.Stmt, error) { return .oc.Prepare() }
func ( *wrapConn) () error { return .oc.Close() }
func ( *wrapConn) () (driver.Tx, error) { return nil, errors.New("unimplmented") }
func ( *wrapConn) ( context.Context, string, []driver.NamedValue) (driver.Result, error) {
return .oc.ExecContext(, , )
}
func ( *wrapConn) ( context.Context, string, []driver.NamedValue) (driver.Rows, error) {
return .oc.QueryContext(, , )
}
func ( *wrapConn) ( context.Context, string) (driver.Stmt, error) {
return .oc.PrepareContext(, )
}
func ( *wrapConn) ( context.Context, driver.TxOptions) (driver.Tx, error) {
return .oc.BeginTx(, )
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |