Standard library / database/sql/driver

driver.ValueConverter

Converts Go values to driver values, returning an error for unsupported input. Expected stdout: 'int64 7\n'.

Formal Syntax & Structure

go syntaxgo
type ValueConverter interface {  ConvertValue(v any) (Value, error)}

Working Example

Example Snippetgo
package main
import (  "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 c driver.ValueConverter = driver.DefaultParameterConverter  v := must(c.ConvertValue(7))  fmt.Printf("%T %v\n", v, v)}
Go Reference