[refactor] implemented receiver, added package comment
This commit is contained in:
parent
10e09bf59f
commit
72ee39a4c7
@ -1,3 +1,4 @@
|
||||
// Package config loads env fils into a Login struct which gets passed to the rest of the application
|
||||
package config
|
||||
|
||||
import (
|
||||
@ -10,7 +11,7 @@ import (
|
||||
type Login struct {
|
||||
User string
|
||||
Pass string
|
||||
Ip string
|
||||
IP string
|
||||
Port string
|
||||
Name string
|
||||
}
|
||||
@ -35,17 +36,16 @@ func CreateEnvFile() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func LoadCredentials() Login {
|
||||
func (L Login) LoadCredentials() Login {
|
||||
err := godotenv.Load(".env")
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
}
|
||||
L.User = os.Getenv("DATABASE_USER")
|
||||
L.Pass = os.Getenv("DATABASE_PASSWORD")
|
||||
L.IP = os.Getenv("DATABASE_IP")
|
||||
L.Port = os.Getenv("DATABASE_PORT")
|
||||
L.Name = os.Getenv("DATABASE_NAME")
|
||||
|
||||
return Login{
|
||||
User: os.Getenv("DATABASE_USER"),
|
||||
Pass: os.Getenv("DATABASE_PASSWORD"),
|
||||
Ip: os.Getenv("DATABASE_IP"),
|
||||
Port: os.Getenv("DATABASE_PORT"),
|
||||
Name: os.Getenv("DATABASE_NAME"),
|
||||
}
|
||||
return L
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user