Skip to content

Commit 7c282a5

Browse files
youshyaddetz
authored andcommitted
feat: add different example
1 parent 49d9421 commit 7c282a5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

demo6/server.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"database/sql"
55
"fmt"
66
"log"
7+
"math/rand"
78
"net/http"
89
"os"
910
"time"
@@ -104,12 +105,11 @@ func main() {
104105
return userAuthService.AddUserNote(c)
105106
})
106107

107-
// we're not checking an error here,
108-
// so even our IDE is mad
109-
str, _ := stringAndError()
108+
names := []string{"John", "Steven", "Arthur", "Sebastien", "Joseph"}
110109

111-
// this error will never be checked
112-
defer onlyError()
110+
name := fmt.Sprintf("%s", names[rand.Intn(len(names))])
111+
112+
fmt.Printf("Hello, %s!", name)
113113

114114
log.Printf("Listening on :%s...\n", port)
115115
if err := s.ListenAndServeTLS(certFile, keyFile); err != http.ErrServerClosed {
@@ -141,8 +141,7 @@ func connectDatabase() *sql.DB {
141141
}
142142
pwd, ok := os.LookupEnv("POSTGRES_PWD")
143143
if !ok {
144-
pwd = "THISISMYSUPERSECRETPASSWORD"
145-
// log.Fatal("POSTGRES_PWD variable must be set")
144+
log.Fatal("POSTGRES_PWD variable must be set")
146145
}
147146
db, ok := os.LookupEnv("POSTGRES_DB")
148147
if !ok {

0 commit comments

Comments
 (0)