sqlx

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSqlDB

func NewSqlDB(cfg *conf.Configuration) *sql.DB

NewSqlDB create a sql.DB instance from config.

Configuration example:

	dbname:
	  driverName: testDriver
	  dsn: root:123456@tcp(127.0.0.1:3306)
	  maxIdleConns: 10
	  maxOpenConns: 100
	  connMaxLifetime:

Encrypted password example:
	dbname:
	  driverName: testDriver
	  dsn: root:${password}@tcp(127.0.0.1:3306)
	  maxIdleConns: 10
	  maxOpenConns: 100
	  connMaxLifetime:
      encryption:
        password: U2FsdGVkX1+tlVEqk7q5J4HmwH0tZg
        method: aes-gcm

if use encrypted password, you need pass the env "DB_SECRET_KEY" which used AES-GCM encrypted by default

func RegisterEncryptor added in v0.5.4

func RegisterEncryptor(name string, e Encryptor)

RegisterEncryptor register a new encryptor

Types

type Encryptor added in v0.5.4

type Encryptor interface {
	Encrypt(plaintext string) (string, error)
	Decrypt(ciphertext string) (string, error)
}

Encryptor is used to encrypt and decrypt password

Jump to

Keyboard shortcuts

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