This is a created article in which the information may have evolved or changed.
The first go Database/sql source analysis article highly evaluates the author (Brad Fitzpatrick memcached, author of the Go Language project group), but personally believes that the go Database/sql is not flawless.
Advantages:
Interface design is simple, clear, consistent, friendly: application layer of the interface and drive layer implementation interface almost consistent, users without pressure;
Disadvantages:
The inner implementation of the package is very complicated and messy, giving the illusion that the logic is complicated or the problem is realized;
This is also the characteristics of Daniel, you do not care about my implementation, I just keep the interface clear, you just use it, as for the internal implementation is my own thing, I do not guarantee readability, I can use any skill I think;
Personal feel Database/sql Package internal realization of unscientific place:
1. In order to achieve concurrency, a large number of use of lock structure: this is against the Golang of the programming philosophy, but sometimes the lock is really a good way to solve the problem, but too many locks in the code, will make the code very ugly;
2. The reuse, recovery, cleanup logic of each entity resource in the package is not clear enough, and it is very confusing to read the code, it is difficult to understand how each entity is dependent, how to survive, how to design, how to test, seriously doubt the author
Is my level is not enough, always feel the realization is not elegant, later think Database/sql author, Brad Fitzpatrick big God is not Daogaoyizhang, is my skill enough, still need refueling.
But I am not unconditional worship of the great God, if I come to realize database/sql, there is no better way, this is really the question of their own should think;