Schema
You can generate Go code from Sql code using Sqlc through frizzante generate schema .

Requirements
You will need a sqlc.yaml file.
version: "2"
sql:
- engine: "sqlite"
    queries: "queries.sql"
    schema: "schema.sql"
    gen:
    go:
        package: "schema"
        out: "lib/schema"
        emit_json_tags: true
        json_tags_case_style: camel
The above configuration indicates a schema.sql file, which will contain your database schema and a queries.sql file, which will contain your sql queries.
Note
For more details, see the official Sqlc documentation for Sqlite .


Define Schema
Define your schema in schema.sql .
create table if not exists sessions(
    id varchar(36) primary key,
    created_at datetime not null,
    updated_at datetime not null
);


Define Queries
Define your queries in queries.sql .
-- name: FindSessionById :one
select * from sessions where id = :id;


Generate Go Code
Run frizzante generate schema to generate your Go code.
This will create a new lib/schema package which contains all your types and functions.


Invoke Queries
You can invoke your queries by creating a new schema object.
package main

import (
    "context"
    "main/lib/databases"
    "main/lib/schema"
)

var database, databaseError = databases.Connect()
var queries = schema.New(database)
var session, _ = queries.FindSessionById(context.Background(), "some-session-id")
Note
The resulting session is of type schema.Session , a type that is automatically generated in lib/schema .