Go Database/sql Source Analysis-External

Source: Internet
Author: User
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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.