As follows showing,  when `-N` is enabled with compiler, it gives the 
expected output.
```
➜  grd more nf2.go
package main

import "os"

func main() {
        f, err := os.Open("nonExistFile")
        fname := f.Name()
        if err != nil {
                println("failed to open file, Error:", err.Error())
                return
        }

        println("filename:", fname)
}
➜  grd go run nf2.go
failed to open file, Error: open nonExistFile: no such file or directory

➜  grd go run -gcflags="-N" nf2.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4782e3]

goroutine 1 [running]:
os.(*File).Name(...)
        /usr/local/go/src/os/file.go:62
main.main()
        /root/grd/nf2.go:7 +0x123
exit status 2

➜  grd go version
go version go1.24.4 linux/amd64
```

-- 
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 visit 
https://groups.google.com/d/msgid/golang-nuts/17b457de-02c3-448f-b659-0445c8357f82n%40googlegroups.com.

Reply via email to