Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"couldn't find _ in program" if -modified and file doesn't exist #24

Open
metaleap opened this issue Apr 22, 2017 · 4 comments
Open

"couldn't find _ in program" if -modified and file doesn't exist #24

metaleap opened this issue Apr 22, 2017 · 4 comments

Comments

@metaleap
Copy link

metaleap commented Apr 22, 2017

Scenario: editing a .go file that's hasn't been saved yet. (For example, for rapid greenfield prototyping of stuff via some sort of go run-based REPL-ish tool like gore.) The source is sent as usual via -modified flag and stdin archive format. When -pos is something like Untitled-1.go:#pos, all documentation requests via -json (say, hovering over the strings.ToLower or anything that should have docs) will always return couldn't find Untitled-1 in program. Or if name is empty, similarly couldn't find in program (2 spaces).

Here's an easy-repro session:

[23:42 me ~/.../github.com/metaleap]$ gogetdoc -json -modified -pos untitled.go:#94
untitled.go
136
package tmp
import "strings"
func test (val string) string {
	if val[0]=='u' {return strings.ToUpper(val)}
	return "Nope not happn'g"
}
gogetdoc: couldn't find untitled.go in program
[23:49 me ~/.../github.com/metaleap]$ 

Of course no file named untitled.go exists on disk, but would be awesome if gogetdoc could handle that, given that it read the program from stdin anyway! The given -pos 94 should be between the T and o of ToUpper if my editor didn't fool me.

@metaleap
Copy link
Author

Oddly enough, just found that guru too gives a strikingly similarly worded message in such a scenario: file Untitled-1 not found in loaded program --- makes me wonder, why look for any file when it's supplied via stdin though!

@zmb3
Copy link
Owner

zmb3 commented Apr 23, 2017

Good catch - I had never even considered such a scenario.

I'll take a look this week.

@metaleap
Copy link
Author

Ever got the chance? ;D

@zmb3
Copy link
Owner

zmb3 commented Dec 14, 2017

Sadly, as you might suspect, I did not. Would happily take a PR to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants