| 301 | } |
| 302 | |
| 303 | func (a *Float32Array) scanBytes(src []byte) error { |
| 304 | elems, err := scanLinearArray(src, []byte{','}, "Float32Array") |
| 305 | if err != nil { |
| 306 | return err |
| 307 | } |
| 308 | if *a != nil && len(elems) == 0 { |
| 309 | *a = (*a)[:0] |
| 310 | } else { |
| 311 | b := make(Float32Array, len(elems)) |
| 312 | for i, v := range elems { |
| 313 | x, err := strconv.ParseFloat(string(v), 32) |
| 314 | if err != nil { |
| 315 | return fmt.Errorf("pq: parsing array element index %d: %w", i, err) |
| 316 | } |
| 317 | b[i] = float32(x) |
| 318 | } |
| 319 | *a = b |
| 320 | } |
| 321 | return nil |
| 322 | } |
| 323 | |
| 324 | // Value implements the driver.Valuer interface. |
| 325 | func (a Float32Array) Value() (driver.Value, error) { |