Skip to content

Instantly share code, notes, and snippets.

View ByChanderZap's full-sized avatar
:electron:
Coding

Neryt Alexander Herrera Iñiguez ByChanderZap

:electron:
Coding
View GitHub Profile
@ByChanderZap
ByChanderZap / manualPreparedStatement.go
Created September 30, 2025 06:40
pattern for using your own prepared statement in go
// We need somewhere to store the prepared statement for the lifetime of our
// web application. A neat way is to embed it in the model alongside the
// connection pool.
type ExampleModel struct {
DB *sql.DB
InsertStmt *sql.Stmt
}
// Create a constructor for the model, in which we set up the prepared
// statement.
@ByChanderZap
ByChanderZap / try-catch.ts
Created February 25, 2025 06:49 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};