Alexey Kim преди 1 година
родител
ревизия
2dccec32d5
променени са 2 файла, в които са добавени 3 реда и са изтрити 7 реда
  1. 2 6
      database/clickhouse.go
  2. 1 1
      database/config.go

+ 2 - 6
database/clickhouse.go

@@ -18,11 +18,7 @@ type _ch struct {
 }
 
 //goland:noinspection GoUnusedExportedFunction
-func NewClickhouse(cfg *Config, debug bool) (Database[driver.Rows, driver.Batch], error) {
-	if cfg == nil || cfg.Clickhouse == nil {
-		return nil, fmt.Errorf("illegal state: `*config.ClickhouseConfig` is nil")
-	}
-
+func NewClickhouse(cfg Config, debug bool) (Database[driver.Rows, driver.Batch], error) {
 	var tlcConfig *tls.Config
 	if cfg.Clickhouse.Params.Secure {
 		tlcConfig = &tls.Config{
@@ -53,7 +49,7 @@ func NewClickhouse(cfg *Config, debug bool) (Database[driver.Rows, driver.Batch]
 	}
 
 	s := &_ch{
-		config: cfg.Clickhouse,
+		config: &cfg.Clickhouse,
 		conn:   session,
 	}
 

+ 1 - 1
database/config.go

@@ -8,7 +8,7 @@ import (
 )
 
 type Config struct {
-	Clickhouse *configCH `yaml:"clickhouse"`
+	Clickhouse configCH `yaml:"clickhouse"`
 }
 
 func (cfg Config) Invalidate() error {