Your function returns nil on the success path, the caller checks err != nil, and the check fires anyway. What happened?
A Go interface is non-nil when it holds a concrete type, even if the concrete pointer value is nil. Returning a typed nil pointer as an error creates an interface value that fails err == nil checks.