How to Connect to SQLite from Go

Connect to SQLite in Go by importing a driver, registering it, and opening a connection with sql.Open.

Connect to SQLite by importing a driver, registering it with database/sql, and opening a connection using the file: URI scheme.

package main

import (
	"database/sql"
	_ "github.com/mattn/go-sqlite3"
)

func main() {
	db, err := sql.Open("sqlite3", "file:mydb.sqlite3?cache=shared")
	if err != nil {
		panic(err)
	}
	defer db.Close()
}