GoLand Does not detect struct definitions/elements in same package different files
I have a program that shows no problems in Visual Studio Code and also compiles just fine from the command line, but GoLand refuses. I have a struct:
type sshPlugin struct {
ports protos.PortsConfig
parserConfig parserConfig
transConfig transactionConfig
pub transPub
}
GoLand outputs:
packetbeat\protos\ssh\ssh.go:32:15: undefined: parserConfig
packetbeat\protos\ssh\ssh.go:33:15: undefined: transactionConfig
packetbeat\protos\ssh\ssh.go:34:15: undefined: transPub
All three of those elements are defined in other files that are part of the same package. Ex:
type transPub struct {
sendRequest bool
sendResponse bool
results protos.Reporter
}
Not sure if this is a bug or I'm missing something. Both definitions are part of files in the ssh package.
Please sign in to leave a comment.
Likely you're trying to compile a file, not a package, so Go compiler knows nothing about any packages in the GOPATH. Try to run package or directory instead.
This just happened to me also, for the second time..
I had Goland open, Ubuntu did some upgrades and logged me out of desktop..
I logged back in, reopened Golang, all of a sudden it was broken; some functions and methods were no longer recognized.
I had build my application the evening before so I know it was working..
I commented out all the code in the file that was no longer recognized, put it in a new file, the errors went away.
I then copy pasted everything back into the original file and now it recognized everything again the way it was..
Weird..
Hi @381401453300-Info, it's a known issue.
Could you please try the workaround from this comment? Does it help?