package main
import (
"fmt"
"os"
"bufio"
"strconv"
"time"
"log"
"math/rand"
"strings"
)
func main () {
seconds := time.Now().Unix()
rand.Seed(seconds)
target := rand.Intn(100)+1
fmt.Println("I have chosen... ")
fmt.Println("can you guess it?")
reader := bufio.NewReader(os.Stdin)
success := false
for guess := 1, guess<=10, guess++ {
fmt.Println("have ", 11-guess, "left")
fmt.Println("make a guess:")
input, err := reader.ReadString('\n')
if err !=nil {
log.Fatal(err)
}
input := string.TrimSpace(input)
guess, err := strconv.Atoi(input)
if err !=nil {
log.Fatal(err)
}
if guess < target {
fmt.Println("low")
} else if guess > target{
fmt.Println("high")
} else {
success = true
fmt.Println("right")
break
}
if !success {
fmt.Println("target is" target)
}
}
}