Standard library / database/sql/driver

driver.Valuer

Lets a type provide a driver value. Value must not panic. database/sql wraps returned errors so errors.Is can inspect them. Expected stdout: 'Ada\n'.

Formal Syntax & Structure

go syntaxgo
type Valuer interface {  Value() (Value, error)}

Working Example

Example Snippetgo
package main
import (  "database/sql"  "database/sql/driver"  "fmt")
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}func main() {  var v driver.Valuer = sql.NullString{String: "Ada", Valid: true}  fmt.Println(must(v.Value()))}
Go Reference