Hi, everyone, I have in trouble about `short variable declaration`

Here is my codes snippet

package utils
import "os"

type FileController struct{
    file *os.File}

func (c *FileController)OpenFile(path string)error{
    c.file, err := os.OpenFile(path,os.O_CREATE | os.O_RDWR,0755)

    //return some value these}


c.file have been declared, but err not.


>From golang spec docs



> Unlike regular variable declarations, a short variable declaration may 
> redeclare variables provided they were originally declared earlier in the 
> same block (or the parameter lists if the block is the function body) with 
> the same type, and at least one of the non-blank variables is new. 



My codes snippet should works, but `GolandIDE` tell me "unresolved 
reference 'err' "


[image: image_3.png]


It's a bug about Goland IDE or just I'm wrong?

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

Reply via email to