Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-02-10 Thread 'Ivan Burak' via golang-nuts
>> Fscanln is when you want to scan *the entire line* in one go, and you know in advance exactly the right number of placeholders to capture. Yes, Brain. This means the documentation needs to be changed a bit, like the blue text in my previous message. And of course, my example of the fix is no

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-02-09 Thread 'Brian Candler' via golang-nuts
You've missed the point of how Fscanln is *supposed* to be different to Fscan. Fscanln is when you want to scan *the entire line* in one go, and you know in advance exactly the right number of placeholders to capture. If there is extra data on the line after these placeholders, then an error i

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-31 Thread tapi...@gmail.com
The documents are too simple to explain clearly on anything. Besides the eating/chomping behavior, does an item include the space/newline following it? Either answer will not satisfy the behavior of the following code, by either answer, there should one case reports an error. https://go.dev/play/

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-30 Thread 'Brian Candler' via golang-nuts
I guess not, but since it uses a plain io.Reader which doesn't support peek or pushback, I can't think of any other behavior which is possible. On Thursday, 30 January 2025 at 19:27:51 UTC tapi...@gmail.com wrote: > On Tuesday, January 28, 2025 at 7:07:15 PM UTC+8 Brian Candler wrote: > > > The

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-30 Thread tapi...@gmail.com
On Tuesday, January 28, 2025 at 7:07:15 PM UTC+8 Brian Candler wrote: > The documentation tells that Fscanln() is similar to Fscan(), my test shows that it isn't true for some cases. "similar" does not mean "the same as". Fscanln chomps the fields given, then chomps the next character. If th

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-28 Thread 'Brian Candler' via golang-nuts
> The documentation tells that Fscanln() is similar to Fscan(), my test shows that it isn't true for some cases. "similar" does not mean "the same as". Fscanln chomps the fields given, then chomps the next character. If the next character is newline, it's happy. If the next character is not a

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-28 Thread 'Ivan Burak' via golang-nuts
Hi Jan Thank you for the test enhancing. Please read my answer to Howard https://groups.google.com/g/golang-nuts/c/tzvKTyaugEk/m/5h2Sm03bDgAJ thanks ivan On Monday, January 27, 2025 at 9:37:46 PM UTC+3 Jan Mercl wrote: > On Mon, Jan 27, 2025 at 6:54 PM 'Ivan Burak' via golang-nuts > wrote: >

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-28 Thread 'Ivan Burak' via golang-nuts
Hi Howard Thank you for the answer. My data is easier, it contains only 2 lines: Go version go1.22.11 windows/amd64 Build simple, secure, scalable systems with Go I did some tests and to speedup coding decided to use Fscanln(). I don't use this function in real programming, it's too slow. Ther

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-27 Thread Howard C. Shaw III
In your example, you are repeatedly reading one 'item' from the line. This is the source of the confusion, as this is not how Fscanln works - when you do this, *each* item is the documented 'final item' after which there must be a newline. That is, your data would look more like this: space sep

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-27 Thread Jan Mercl
On Mon, Jan 27, 2025 at 6:54 PM 'Ivan Burak' via golang-nuts wrote: WAI: https://go.dev/play/p/4bWHGemItL_9 -- 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 gola

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-27 Thread 'Ivan Burak' via golang-nuts
Hi Ian >> Check the error result from Fscanln. Thank you for the advice but I still have some arguments about wrong behavior of Fscanln() or not fully correct documentation for it.. Let’s look at the next lines from the documentation. *func **Fscan*

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-26 Thread Ian Lance Taylor
On Sun, Jan 26, 2025 at 4:51 PM 'Ivan Burak' via golang-nuts wrote: > > Fscan() eats 1st char in scanning values if the values aren't a first value > in a line. > > The documentation tells: "Fscanln is similar to Fscan, but stops scanning at > a newline and after the final item there must be a n

[go-nuts] Fscan() eats 1st char in scanning values

2025-01-26 Thread 'Ivan Burak' via golang-nuts
Fscan() eats 1st char in scanning values if the values aren't a first value in a line. The documentation tells: "Fscanln is similar to Fscan , but stops scanning at a newline and after the final item there must be a newline or EOF." The test discover