From d2c9ebc2efcbfca5a92108d8e48a4ec850fb3137 Mon Sep 17 00:00:00 2001 From: Tikhon Fedulov Date: Sun, 24 Dec 2023 13:57:58 +0300 Subject: [PATCH] Use local variables in fieldPosByName and fix errors --- rows.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rows.go b/rows.go index 2bb95d1f..1ad91765 100644 --- a/rows.go +++ b/rows.go @@ -668,11 +668,11 @@ func fieldPosByName(fldDescs []pgconn.FieldDescription, field string) (i int) { i = -1 for i, desc := range fldDescs { - // Support snake and spinal case. - desc.Name = strings.ReplaceAll(desc.Name, "_", "") - desc.Name = strings.ReplaceAll(desc.Name, "-", "") + // Snake case support. + field = strings.ReplaceAll(field, "_", "") + descName := strings.ReplaceAll(desc.Name, "_", "") - if strings.EqualFold(desc.Name, field) { + if strings.EqualFold(descName, field) { return i } }