7
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?

0

1 Answer 1

12

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())
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.