You can do some adjustments, creating a struct called User for id, name, age outside context and initiate u := User{} for example.
defer rows.Close() I understand you can remove it because it is automatic close when the row is empty. But closing you can solve enumerating, but can’t understand when this can happen, maybe someone with more experience can add more comments.
Next steps you can create functions like selectUserByAge(db *sql.DB, int age) (*User, error)
Don’t hardcode connection information in the go file.
Put the connection parameters in a file and read that file.
Most programs need configuration parameters, so you can put the connection string as a parameter in such a file.