Browse Source

Update main.go

Volodymyr Tkach 2 years ago
parent
commit
feb8b1809a
1 changed files with 5 additions and 4 deletions
  1. 5 4
      main.go

+ 5 - 4
main.go

@@ -110,11 +110,12 @@ func main() {
 	err = db.QueryRow(context.Background(), "SELECT id, name FROM users WHERE id=$1", 5).Scans(&row)
 	if err != nil && err != sql.ErrNoRows {
 		panic(fmt.Sprintf("%s", err))
-	}
-	if err != sql.ErrNoRows {
-		fmt.Printf("ID: %d, Name: %s\n", row.ID, row.Name)
 	} else {
-		fmt.Printf("Record not found\n")
+		if err != sql.ErrNoRows {
+			fmt.Printf("ID: %d, Name: %s\n", row.ID, row.Name)
+		} else {
+			fmt.Printf("Record not found\n")
+		}
 	}
 
 	// Close DB connection