jackc/pgx · error
cannot convert to Line
Error message
cannot convert %v to Line
What it means
Line.Set is the catch-all conversion path for building a pgtype.Line from arbitrary Go values, but no conversions are implemented — every non-supported input falls through to this unconditional error naming the source type. It exists to satisfy the Set interface contract while signaling that Line supports no direct Set conversions.
Solutions
- Assign the struct fields directly: line.A, line.B, line.C, line.Valid
- Construct a Line literal (Line{A: 1, B: 2, C: 3, Valid: true}) instead of calling Set
- Use Scan with the textual representation for string sources
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at pgtype/line.go:38 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04).
Data as JSON: /api/errors/6282a69f5de62bee.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/line.go:38
type Line struct {
A, B, C float64
Valid bool
}
// ScanLine implements the [LineScanner] interface.
func (line *Line) ScanLine(v Line) error {
*line = v
return nil
}
// LineValue implements the [LineValuer] interface.
func (line Line) LineValue() (Line, error) {
return line, nil
}
func (line *Line) Set(src any) error {
return fmt.Errorf("cannot convert %v to Line", src)
}
// Scan implements the [database/sql.Scanner] interface.
func (line *Line) Scan(src any) error {
if src == nil {
*line = Line{}
return nil
}
if src, ok := src.(string); ok {
return scanPlanTextAnyToLineScanner{}.Scan([]byte(src), line)
}
return fmt.Errorf("cannot scan %T", src)
}
// Value implements the [database/sql/driver.Valuer] interface.
func (line Line) Value() (driver.Value, error) {View on GitHub (pinned to ec1a0befd2)