gorm

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: BSD-3-Clause Imports: 12 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gorm

Github template for new libraries

Static Badge

GoDoc GitHub stars Go Report Card codecov

Versions

Stable Version GitHub Release GitHub Release

Also available in other languages

Go Implementation PHP Implementation JavaScript Implementation

Introduction

This is template repository for new libraries

Important

  • Edit go.mod and rename to your package module
  • Uncomment .github/workflows/tests.yml

Contributing

Read Contributing

Contributors

JanGalek actions-user

Join our Discord Community! 🎉

Discord

Click above to join our community on Discord!

Documentation

Index

Constants

View Source
const (
	Reset       = "\033[0m"
	Red         = "\033[31;1m"
	Green       = "\033[32m"
	Yellow      = "\033[33m"
	Blue        = "\033[34m"
	Magenta     = "\033[35;1m"
	Cyan        = "\033[36m"
	White       = "\033[37m"
	BlueBold    = "\033[34;1m"
	MagentaBold = "\033[35;1m"
	RedBold     = "\033[31;1m"
	YellowBold  = "\033[33;1m"
)

Variables

This section is empty.

Functions

func New

func New(cfg *Config) (*o_gorm.DB, error)

Types

type Config

type Config struct {
	Driver          string        `json:"driver" yaml:"driver" mapstructure:"driver"`
	Host            string        `json:"host" yaml:"host" mapstructure:"host"`
	Port            int           `json:"port" yaml:"port" mapstructure:"port"`
	User            string        `json:"user" yaml:"user" mapstructure:"user"`
	Password        string        `json:"password" yaml:"password" mapstructure:"password"`
	DBName          string        `json:"dbname" yaml:"dbname" mapstructure:"dbname"`
	SSLMode         string        `json:"sslmode" yaml:"sslmode" mapstructure:"sslmode"`
	TimeZone        string        `json:"timezone" yaml:"timezone" mapstructure:"timezone"`
	MaxIdleConns    int           `json:"max_idle_conns" yaml:"max_idle_conns" mapstructure:"max_idle_conns"`
	MaxOpenConns    int           `json:"max_open_conns" yaml:"max_open_conns" mapstructure:"max_open_conns"`
	ConnMaxLifetime time.Duration `json:"conn_max_lifetime" yaml:"conn_max_lifetime" mapstructure:"conn_max_lifetime"`
	Debug           bool          `json:"debug" yaml:"debug" mapstructure:"debug"`
	Logger          LoggerConfig  `json:"logger" yaml:"logger" mapstructure:"logger"`
}

type GouefGormLogger added in v1.0.2

type GouefGormLogger struct {
	LogLevel                  logger.LogLevel
	SlowThreshold             time.Duration
	IgnoreRecordNotFoundError bool
	ParameterizedQueries      bool
	Colorful                  bool
	// contains filtered or unexported fields
}

GouefGormLogger upravuje výstup tak, aby duration byl přímo v logu

func NewGouefGormLogger added in v1.0.2

func NewGouefGormLogger(config LoggerConfig) *GouefGormLogger

func (*GouefGormLogger) Error added in v1.0.2

func (l *GouefGormLogger) Error(ctx context.Context, msg string, data ...interface{})

func (*GouefGormLogger) Info added in v1.0.2

func (l *GouefGormLogger) Info(ctx context.Context, msg string, data ...interface{})

func (*GouefGormLogger) LogMode added in v1.0.2

func (l *GouefGormLogger) LogMode(level logger.LogLevel) logger.Interface

func (*GouefGormLogger) Trace added in v1.0.2

func (l *GouefGormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace se volá po každém SQL dotazu a tady si poskládáme duration přesně podle sebe

func (*GouefGormLogger) Warn added in v1.0.2

func (l *GouefGormLogger) Warn(ctx context.Context, msg string, data ...interface{})

type LoggerConfig added in v1.0.1

type LoggerConfig struct {
	SlowThreshold             time.Duration `json:"slow_threshold" yaml:"slow_threshold" mapstructure:"slow_threshold"`
	LogLevel                  string        `json:"log_level" yaml:"log_level" mapstructure:"log_level"`
	IgnoreRecordNotFoundError bool          `json:"ignore_record_not_found_error" yaml:"ignore_record_not_found_error" mapstructure:"ignore_record_not_found_error"`
	ParameterizedQueries      bool          `json:"parameterized_queries" yaml:"parameterized_queries" mapstructure:"parameterized_queries"`
	Colorful                  bool          `json:"colorful" yaml:"colorful" mapstructure:"colorful"`
}

Jump to

Keyboard shortcuts

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