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
  • 158,998
  • 31
  • 281
  • 276
liam
  • 341
  • 2
  • 5
  • 9

1 Answers1

11

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
  • 534
  • 5
  • 6