5
package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {
    fmt.Println("insert y value here: ")
    input := bufio.NewScanner(os.Stdin)
    fmt.Println(input.Text)
}

How do I make the program wait, until the user inputs data?

peterSO
  • 146,831
  • 29
  • 256
  • 250
liam
  • 341
  • 2
  • 4
  • 9
  • 3
    Please don't use line numbers. It makes it hard for people to copy and paste your program to reproduce your problem. – peterSO Nov 20 '15 at 17:58

1 Answers1

8

Scanner isn't really ideal for reading command line input (see the answer HectorJ referenced above), but if you want to make it work, it's a call to Scan() that you're missing (also note that Text() is a method call):

func main() {
    fmt.Print("insert y value here: ")
    input := bufio.NewScanner(os.Stdin)
    input.Scan()
    fmt.Println(input.Text())
}
dahc
  • 494
  • 5
  • 5