Go version
latest
Output of go env in your module/workspace:
What did you do?
I was reading through the source code of database/sql/driver to learn to write better go and out of interest how a language is designed.
What did you see happen?
I suspect no errNilPtr will be returned in
https://github.com/golang/go/blob/master/src/database/sql/convert.go#L272-L278
case time.Time:
switch d := dest.(type) {
case *time.Time:
*d = s
return nil
case *string:
*d = s.Format(time.RFC3339Nano)
return nil
case *[]byte:
if d == nil {
return errNilPtr
}
*d = []byte(s.Format(time.RFC3339Nano))
return nil
To confirm this i didn't see any tests for the returning of a nilptr err.
What did you expect to see?
Since dest has to be pointer it would be best to first test if the dest is a nil ptr at the top level of the function.
https://github.com/golang/go/blob/master/src/database/sql/convert.go#L219-L221
func convertAssignRows(dest, src any, rows *Rows) error {
if d == nil {
return errNilPtr
}
// Common cases, without reflect.
Go version
latest
Output of
go envin your module/workspace:What did you do?
I was reading through the source code of database/sql/driver to learn to write better go and out of interest how a language is designed.
What did you see happen?
I suspect no errNilPtr will be returned in
https://github.com/golang/go/blob/master/src/database/sql/convert.go#L272-L278
To confirm this i didn't see any tests for the returning of a nilptr err.
What did you expect to see?
Since dest has to be pointer it would be best to first test if the dest is a nil ptr at the top level of the function.
https://github.com/golang/go/blob/master/src/database/sql/convert.go#L219-L221