On Wed, 29 May 2019 at 18:27, Mark Bauermeister <warfan2...@gmail.com> wrote:
> I'm in the process of writing a text adventure parser. > By default, the parser simply uses Stdin. > > i e > > for { > fmt.Print(">>> ") > > reader := bufio.NewScanner(os.Stdin) > for reader.Scan() { > switch reader.Text() { > ... > ... > > This is quite convenient. However, I now want to be able to pass in text > from outside this for-loop. Say I have a function "Invoke(arg string)" > which I should be able to call to pass > arguments straight to the Scanner interface. > > What would be the most straightforward way to achieve this? > https://golang.org/pkg/strings/#NewReader should do what you require. > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/b34d4bea-d819-4832-9ebd-db11709d6b0c%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/b34d4bea-d819-4832-9ebd-db11709d6b0c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJhgacjbQR6k9c0Js%2Bqi8iY4CLHY07LP3To4p62ukv1VmXyEoA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.