Understanding the return in db.Prepare

In database/sql/driver/driver.go the interface Conn contains Prepare function which returns Stmt.

type Conn interface {
	// Prepare returns a prepared statement, bound to this connection.
	Prepare(query string) (Stmt, error)

From Here My understanding is:-

The definition of Prepare function must be written in the driver which we are going to import.

Prepare def in driver:-

func (c *Conn) Prepare(query string) (driver.Stmt, error) {
	os, err := c.PrepareODBCStmt(query)
	if err != nil {
		return nil, err
	return &Stmt{c: c, os: os, query: query}, nil

when I checked def of driver.Stmt and the return Stmt , Both are different.
How this is handled?


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.