Skip to content

Commit

Permalink
CHat server Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMartynenko committed Mar 13, 2024
1 parent 3f55924 commit afa4c8a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internal/config/env/pg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package env

import (
"errors"
"github.com/AndreiMartynenko/chat-server/internal/config"
"os"
)

var _ config.PGConfig = (*pgConfig)(nil)

const (
dsnEnvName = "PG_DSN"
)

type pgConfig struct {
dsn string
}

//NewPGConfig

func NewPGConfig() (*pgConfig, error) {
dsn := os.Getenv(dsnEnvName)
if len(dsn) == 0 {
return nil, errors.New("pg dsn not found")
}

return &pgConfig{
dsn: dsn,
}, nil
}

// DSN

func (cfg *pgConfig) DSN() string {
return cfg.dsn
}

0 comments on commit afa4c8a

Please sign in to comment.