On Tue, Apr 12, 2022 at 9:53 AM Rory Campbell-Lange
<r...@campbell-lange.net> wrote:

> Attempting to write to a named file panics on go 1.17 on Linux with:
>
>     panic: runtime error: invalid memory address or nil pointer dereference
>     [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x46123d]

Not providing the backtrace means other have to guess where the
program actually failed.

The 'output` variable is nil in the 'io.WriteString' statement, the
panic is legitimate. The variable 'output', declared within the block
after 'else' is a different variable because it is not assigned, using
'=', but declared, using ':='. Go has blocks scope very much like C
and most other languages.

-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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-VunMVdjO%2B-0t12yEJiNQcKFZctSsDOZSaNoCyffU1b5g%40mail.gmail.com.

Reply via email to