This commit is contained in:
Max 2024-09-07 21:27:57 +03:00
parent 7665ca24c4
commit c1fa708575
5 changed files with 37 additions and 6 deletions

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"cSpell.words": [
"godotenv"
]
}

1
enshi/.gitignore vendored
View File

@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
secret.env
# Editor directories and files
.vscode/*

View File

@ -49,6 +49,7 @@ github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZ
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/pgx/v5 v5.7.0 h1:FG6VLIdzvAPhnYqP14sQ2xhFLkiUQHCs6ySqO91kF4g=
github.com/jackc/pgx/v5 v5.7.0/go.mod h1:awP1KNnjylvpxHuHP63gzjhnGkI1iw+PMoIwvoleN/8=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
@ -98,6 +99,7 @@ golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@ -1,26 +1,47 @@
package main
import (
"context"
"fmt"
"os"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/joho/godotenv"
)
func main() {
func lookupEnv(dest *string, envVar string) error {
if v, exists := os.LookupEnv(envVar); !exists {
return fmt.Errorf("%v not found in local env", envVar)
} else {
*dest = v
return nil
}
}
func main() {
var bd_pass, bd_user string
var err error
if err = godotenv.Load("secret.env"); err != nil {
fmt.Printf("%v", err)
return
}
var test1 string
var exists bool
if test1, exists = os.LookupEnv("TEST1"); !exists {
if err := lookupEnv(&bd_pass, "BD_PASSWORD"); err != nil {
fmt.Printf("%v", err)
return
}
if err := lookupEnv(&bd_user, "BD_USER"); err != nil {
fmt.Printf("%v", err)
return
}
fmt.Printf("Hey!, %v", test1)
Dbx, err := pgxpool.New(context.Background(), fmt.Sprintf("postgres://%v:%v@nekiiinkognito.ru:5432/enshi_db", bd_user, bd_pass))
if err != nil {
fmt.Printf("%v", err)
return
}
print(Dbx)
fmt.Printf("Hey!, %v", "you")
}

View File

@ -1 +1,3 @@
TEST=HELLO_WORLD
TEST=HELLO_WORLD
BD_PASSWORD=B40B6D7C104C649A0A0517F99C8EAA24
BD_USER=neki