add basic chat loop
This commit is contained in:
29
cmd/chat/chat.go
Normal file
29
cmd/chat/chat.go
Normal file
@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
fmt.Println("Go CLI Chat App")
|
||||
fmt.Println("---------------------")
|
||||
|
||||
for {
|
||||
fmt.Print("You: ")
|
||||
text, _ := reader.ReadString('\n')
|
||||
text = strings.TrimSpace(text) // Remove leading and trailing whitespace
|
||||
|
||||
// Process the input. For now, we'll just echo it back.
|
||||
fmt.Printf("App: You said, %s\n", text)
|
||||
|
||||
// Check if the user wants to exit.
|
||||
if text == "exit" {
|
||||
fmt.Println("Exiting chat...")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user