Post

GoLangGoLang

A
Athiq mohd

Posted on 19th April 2024|36 views

0
votes

Golang Read From Stdin

How to read from stdin in Go?

Answers
P
sumana reddy

Posted on 19th April 2024

To read from standard input stream use os.Stdin like this example

scanner := bufio.NewScanner(os.Stdin)

for scanner.Scan() {

fmt.Println(scanner.Text())

}

 

if err := scanner.Err(); err != nil {

log.Println(err)

}

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos