Reading multi line input from user

58 views
Skip to first unread message

Durga Someswararao G

unread,
Jun 21, 2020, 10:19:24 AM6/21/20
to golang-nuts
Hi,

I am trying to read multi line user input, which I don't know the count of those lines. Is there any way to do it.

Eg:

User will give one sample piece of code like below we have to read complete code without skipping content. As it is a piece of code we cannot get number of lines we have to read.
import java.io.*;

public class SquareNum {

   public static void main(String args[]) throws IOException
   {
      System.out.println("This is a small Java Program!");
   }
}
Thanks

Miguel Angel Rivera Notararigo

unread,
Jun 21, 2020, 11:56:07 AM6/21/20
to Durga Someswararao G, golang-nuts
Hi! you may try this https://play.golang.org/p/hDDyzm6IfED or this https://play.golang.org/p/MoKAbIbtR_J, but the user cannot edit previous lines and he/she have to hit Ctrl + D when is done
Reply all
Reply to author
Forward
0 new messages