On Tue, Apr 12, 2022 at 9:53 AM Rory Campbell-Lange
<
ro...@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