1. Cédric Bonhomme
  2. GoTalk

Commits

Cédric Bonhomme  committed 74ba979

Asks first for the name of the client.

  • Participants
  • Parent commits 1a13482
  • Branches default

Comments (0)

Files changed (1)

File client.go

View file
  • Ignore whitespace
     }
 
     inputReader := bufio.NewReader(os.Stdin)
-    fmt.Println("Your name:")
-    //clientName, _ := inputReader.ReadString('\n')
-    //trimmedClient := strings.Trim(clientName, "n")
+    fmt.Println("Please give yourname. Type Q to quit.")
+    clientName, _ := inputReader.ReadString('\n')
+    trimmedInput := strings.Trim(clientName, "\n")
 
     for {
-        fmt.Println("What to send to the server? Type Q to quit.")
-        input, _ :=inputReader.ReadString('\n')
-        trimmedInput := strings.Trim(input, "\n")
+        _, err = conn.Write([]byte(trimmedInput))
+        fmt.Print("you> ")
+        input, _ := inputReader.ReadString('\n')
+        trimmedInput = strings.Trim(input, "\n")
 
         if trimmedInput == "Q" {
             return
         }
 
-        _, err = conn.Write([]byte(trimmedInput))
+        
     }
 }