Creating and accessing your database
In this section, we will explore SQL databases and how to use them in Go. I’ve selected SQL databases because they are the most widely used in APIs, but you can use any database you want. The concepts are the same. At the end of the day, what you want is to use the database that best fits your needs. For simplicity’s sake, we are going to use SQLite.
Go is excellent when you use SQL databases because it includes, by default, a standard SQL interface that all the SQL database libraries share. This means that you can change the database you are using without changing the Go code that interacts with the database (but, probably, you need to adapt the SQL code to fit your database). So, you import and use the driver whenever you want to use a database.
For example, this is how you access a SQLite database in Go:
package main
import (
  "database/sql"
  "fmt"
  _ "github.com/mattn/go-sqlite3"
)...