How to go to implement bolivarism?

I have an abstract package nsql. I want to make the driver to different nosql databases. (Ala analogue package database/sql only for nosql). How to do that correctly?
July 8th 19 at 11:26
3 answers
July 8th 19 at 11:28
Solution
What if there are?
https://github.com/avelino/awesome-go#database-drivers

func InitDatabase(driver, dbPath string) error {
 var db gorm.DB
 var err error

 switch driver {
 case "sqlite3":
 db, err = gorm.Open("sqlite3", dbPath)
 if err != nil {
 return err
}
break
 case "mysql":
 db, err = gorm.Open("mysql", dbPath)
 if err != nil {
 return err
}
break
 case "postgres":
 db, err = gorm.Open("postgres", dbPath)
 if err != nil {
 return err
}
break
default:
 return fmt.Errorf("Unknown database driver of %v", driver)
 }
and I want to jump to another nosql? (that's the part I need bolivarism) - Brody_Dickins commented on July 8th 19 at 11:31
: if you have to jump from one to another, you should read about the architecture to understand when and which tool to use. - sherwood_Daugherty commented on July 8th 19 at 11:34
damn. And how low smazannost components, etc.? As no polyfoniska to do it ? - Brody_Dickins commented on July 8th 19 at 11:37
: it is not clear what you mean. To use interfaces? Anoint the reflection? - sherwood_Daugherty commented on July 8th 19 at 11:40
: I want to make polyformism as in the boxed packages to work with sql - Brody_Dickins commented on July 8th 19 at 11:43
: so do. Will have to cover all interfaces and to cry when they realize how this is a difficult task. Try to upload to github and wait for help from komyuniti. One make it difficult. - sherwood_Daugherty commented on July 8th 19 at 11:46
: SPS. - Brody_Dickins commented on July 8th 19 at 11:49
my experience in the bad code has made the implementation of 30 lines XD - Brody_Dickins commented on July 8th 19 at 11:52
July 8th 19 at 11:30
Solution
July 8th 19 at 11:32
Solution
As I understand it, the package should be described in a interface to the DBMS. If you want to add support for new database, its driver must implement this interface.

For example, Steve has a package aerofs – abstract file system. To support the new FS written framework that implements the appropriate interfaces, and is connected to the package.

Find more questions by tags Go