
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
github.com/DropFan/go-sqlbuilder
A lightweight and fluent SQL query builder for Go, designed to make database query construction simple, safe, and maintainable. It supports multiple SQL dialects and provides a rich set of features for building complex queries.
go get -u github.com/DropFan/go-sqlbuilder
import (
builder "github.com/DropFan/go-sqlbuilder"
)
// Create a new builder instance
b := builder.New()
// Simple SELECT query
query, err := b.Select("id", "name", "age").
From("users").
Where(builder.Eq("status", "active")).
Build()
// INSERT query
query, err = b.Insert("users", "name", "age").
Values([]interface{}{"John", 25}).
Build()
// INSERT ... ON DUPLICATE KEY UPDATE
query, err = b.InsertOrUpdate("users",
&builder.FieldValue{Name: "name", Value: "John"},
&builder.FieldValue{Name: "age", Value: 25}).
Build()
// UPDATE query
query, err = b.Update("users",
&builder.FieldValue{Name: "age", Value: 26},
&builder.FieldValue{Name: "status", Value: "inactive"}).
Where(builder.Eq("id", 1)).
Build()
// DELETE query
query, err = b.Delete("users").
Where(builder.Eq("id", 1)).
Build()
// Complex WHERE clause with AND/OR conditions
query, err := b.Select("*").
From("users").
Where(
builder.Eq("status", "active"),
builder.Gt("age", 18),
).
And(
builder.In("role", "admin", "moderator"),
).
Or(
builder.Between("last_login", "2023-01-01", "2023-12-31"),
).
Build()
// Using IN operator
query, err = b.Select("*").
From("users").
Where(builder.In("role", "admin", "moderator", "editor")).
Build()
// Using BETWEEN operator
query, err = b.Select("*").
From("users").
Where(builder.Between("age", 18, 30)).
Build()
// MySQL dialect (default)
b.SetDialector(builder.MysqlDialector)
// Output: SELECT `id`, `name` FROM `users` WHERE `age` > ?
// PostgreSQL dialect
b.SetDialector(builder.PostgresDialector)
// Output: SELECT "id", "name" FROM "users" WHERE "age" > $1
// SQLite dialect
b.SetDialector(builder.SQLiteDialector)
// Output: SELECT "id", "name" FROM "users" WHERE "age" > ?
// Using raw SQL when needed
query, err := b.Raw("SELECT * FROM users WHERE id = ?", 1).Build()
Contributions are welcome! Feel free to:
Please ensure your pull request adheres to the following guidelines:
Author: Tiger
Email: DropFan@Gmail.com
Wechat: Hacking4fun
Telegram: DropFan
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.