A golang orm library

Recently open sourced gosql golang orm library with golang style syntax.

Elegant syntax, support batch insertion, easily nested conditions, handle various complex query SQL, such as: and , or combination
Full syntax support: for update lock, is null, exists subquery, etc. Basically all SQL syntax

The style is as follows:

user: = & UserModel {}
err: = db.Fetch (user,
    gosql.Columns ("id", "name"),
    gosql.Where ("id", 1),
    gosql.Where ("[like] name", "j%")
    gosql.OrWhere (func (s * Clause) {
        s.Where ("[> =] score", "90")
        s.Where ("[<=] age", "100")
    GroupBy ("type"),
    OrderBy ("score DESC"),


-Golang-style SQL generation
-Unlimited nesting query
-Reading and Writing Separation
-Delay connection creation
-ORM mapping structure
-Transactions transaction support
-Versatile versatile
-Clean Code
-supports bulk insert




The SQL builder style looks quite strange. How is the Go code in the example any easier to read then the SQL? The same can be said for the conditional expressions. Why not just write SQL?

Thanks for reading, usually when writing native SQL, you will find some problems:
The placeholder for the β€œin” condition needs to be determined according to the parameters
The number of where conditions is not easy to determine


package main

import (

    _ "github.com/go-sql-driver/mysql"

type UserModel struct {
    ID   int    `db:"id"`
    Name string `db:"name"`

func (u *UserModel) TableName() string {
    return "my_user"

func main() {
    db := gosql.NewCluster(
        gosql.AddDb("mysql", "user:password@tcp("),
    user := &UserModel{}
    err := db.Fetch(user, gosql.Where("id", 1), gosql.Where("[like]name", "j%"))
    if err != nil {