FAQ
Following program using Fscanf panics (which should not panic in the first
place IMO and I've filed github issue for it -
https://github.com/golang/go/issues/10853),

http://play.golang.org/p/_MVeoI7wif

Another similar program using Scanf seems to work fine,

http://play.golang.org/p/rrBjFXuC0a

$ go run 2.go < input

$ hexdump input
0000000 31 0a 32 0a
0000004





--
Regards,
Aamir

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Jan Mercl at May 14, 2015 at 12:39 pm

    On Thu, May 14, 2015 at 2:20 PM Aamir Khan wrote:

    Following program using Fscanf panics (which should not panic in the
    first place IMO and I've filed github issue for it -
    https://github.com/golang/go/issues/10853),

    http://play.golang.org/p/_MVeoI7wif

    The above program must panic because it executes a path where you put a
    panic statement at line 19.

    Without panics: http://play.golang.org/p/gCYOnPgM-1

    Moreover, the error is expected because (see http://golang.org/pkg/fmt/ ):
    "Scanf, Fscanf and Sscanf require newlines in the input to match newlines
    in the format"

    Fixed: http://play.golang.org/p/gv78LGpjUW

    -j

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Aamir Khan at May 14, 2015 at 1:17 pm
    That doesn't answer the question as to why there's a difference between the
    two programs one using Fscanf and other using Scanf with input specified.

    On Thu, May 14, 2015 at 9:39 PM, Jan Mercl wrote:

    On Thu, May 14, 2015 at 2:20 PM Aamir Khan wrote:

    Following program using Fscanf panics (which should not panic in the
    first place IMO and I've filed github issue for it -
    https://github.com/golang/go/issues/10853),

    http://play.golang.org/p/_MVeoI7wif

    The above program must panic because it executes a path where you put a
    panic statement at line 19.

    Without panics: http://play.golang.org/p/gCYOnPgM-1

    Moreover, the error is expected because (see http://golang.org/pkg/fmt/
    ): "Scanf, Fscanf and Sscanf require newlines in the input to match
    newlines in the format"
    Fixed: http://play.golang.org/p/gv78LGpjUW

    -j

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Regards,
    Aamir

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Aamir Khan at May 14, 2015 at 1:37 pm
    On Thu, May 14, 2015 at 9:39 PM, Jan Mercl wrote:
    On Thu, May 14, 2015 at 2:20 PM Aamir Khan wrote:

    Following program using Fscanf panics (which should not panic in the
    first place IMO and I've filed github issue for it -
    https://github.com/golang/go/issues/10853),

    http://play.golang.org/p/_MVeoI7wif

    The above program must panic because it executes a path where you put a
    panic statement at line 19.

    Without panics: http://play.golang.org/p/gCYOnPgM-1

    Moreover, the error is expected because (see http://golang.org/pkg/fmt/
    ): "Scanf, Fscanf and Sscanf require newlines in the input to match
    newlines in the format"
    How would you explain this http://play.golang.org/p/83J2--QWS1?
    Fixed: http://play.golang.org/p/gv78LGpjUW

    -j

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Regards,
    Aamir

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • James Bardin at May 14, 2015 at 1:57 pm

    On Thursday, May 14, 2015 at 9:37:32 AM UTC-4, Aamir Khan wrote:

    How would you explain this http://play.golang.org/p/83J2--QWS1?
    The existing issue has more explanation
    https://golang.org/issue/9459

    If you want to match both, you can put a newline in the format string.





    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Aamir Khan at May 14, 2015 at 2:17 pm
    On Thu, May 14, 2015 at 10:57 PM, James Bardin wrote:
    On Thursday, May 14, 2015 at 9:37:32 AM UTC-4, Aamir Khan wrote:


    How would you explain this http://play.golang.org/p/83J2--QWS1?
    The existing issue has more explanation
    https://golang.org/issue/9459

    If you want to match both, you can put a newline in the format string.

    actually, the format and input matches without newline -
    http://play.golang.org/p/GhBB9SRP0H

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Regards,
    Aamir

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 14, '15 at 12:20p
activeMay 14, '15 at 2:17p
posts6
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase