From 7c282a52191ecdf88357eb115d2ae709ffc905b6 Mon Sep 17 00:00:00 2001 From: Artur Kondas Date: Mon, 14 Aug 2023 22:02:50 +0200 Subject: [PATCH] feat: add different example --- demo6/server.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/demo6/server.go b/demo6/server.go index ebffb79..bec0705 100644 --- a/demo6/server.go +++ b/demo6/server.go @@ -4,6 +4,7 @@ import ( "database/sql" "fmt" "log" + "math/rand" "net/http" "os" "time" @@ -104,12 +105,11 @@ func main() { return userAuthService.AddUserNote(c) }) - // we're not checking an error here, - // so even our IDE is mad - str, _ := stringAndError() + names := []string{"John", "Steven", "Arthur", "Sebastien", "Joseph"} - // this error will never be checked - defer onlyError() + name := fmt.Sprintf("%s", names[rand.Intn(len(names))]) + + fmt.Printf("Hello, %s!", name) log.Printf("Listening on :%s...\n", port) if err := s.ListenAndServeTLS(certFile, keyFile); err != http.ErrServerClosed { @@ -141,8 +141,7 @@ func connectDatabase() *sql.DB { } pwd, ok := os.LookupEnv("POSTGRES_PWD") if !ok { - pwd = "THISISMYSUPERSECRETPASSWORD" - // log.Fatal("POSTGRES_PWD variable must be set") + log.Fatal("POSTGRES_PWD variable must be set") } db, ok := os.LookupEnv("POSTGRES_DB") if !ok {