utcer

package module
v0.0.0-...-5de0f99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 3 Imported by: 1

README

UTCer

UTCer is a wrapper for database/sql/driver.Driver that sets time.Time location to UTC.

Motivation

.UTC() appears again and again in projects that store date and time as local timestamp in UTC. UTCer mitigates this pain in exchange for inconvenience of timestamp with time zone.

How It Works

UTCer implements and uses a driver.NamedValueChecker which replaces Value of driver.NamedValue with Value.UTC() when its type is time.Time.

Usage

pgx
import (
	"database/sql"

	_ "github.com/hirofumi/utcer/utcpgx"
)

func open(dsn string) (*sql.DB, error){
	return sql.Open("utcpgx", dsn)
}
pq
import (
	"database/sql"

	_ "github.com/hirofumi/utcer/utcpq"
)

func open(dsn string) (*sql.DB, error){
	return sql.Open("utcpq", dsn)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(d driver.Driver) driver.Driver

Types

This section is empty.

Directories

Path Synopsis
pgxutc module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL