-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
add feature can auto add nested local package's function in go . #248
Comments
"Parsing" the package to get the needed (and only the needed symbols) is actually very hard Let's suppose your are indeed writing package Foo. You've already finished foo, now you're trying to write bar func bar () {
test := 8 // snippet to
bar := foo()+2 *test // send to
fmt.Println(bar) // sniprun
...TODO
}
//Another function not working yet
func test(){
Todo
Sniprun would have to understand that for evaluating the snippet, it needs to fetch The general problem is too hard for me to implement, so I would need to plug into an LSP and that's already hard |
thank you , but for golang it is not very hard to do that because of gopls. package main
import "fmt"
func bar() {
test := 8 // snippet to
bar := foo() + 2*test // send to
fmt.Println(bar) // sniprun
}
func foo() int {
return 1
}
// Another function not working yet
func test() int {
return 0
} suppose i want to run function bar.
now i know bar function is in 5:6
now i got the same package's function foo in /root/vm/exports/lib/test/main.go:11:6-9 func foo() int {
return 1
} add it to the last of generated main.go and thats ok. it is not very hard but trivial and boreing. i am not a ruster, and its hard to implement these logic in rust for me. maybe i can do it in lua for my personal use. but i hope it can add to go_orignal.rs logic. At last, thanks for your great work , it is more powerful than vscode's same plugin. |
because of golang's package is flat, it can only support logic write in same dir, if two function is not in same file, simple loop dir so it can support all nest function call except init() function and global var. And if two function not in same file has other problem is how to add and organize import, and in this situation, i dont have a good idea. also for dot import like import . "foo" |
Is your feature request related to a problem? Please describe.
#249
Describe the solution you'd like
if i select a function to run , if the function called other packeages functions, it works fine, but if the function called current packages function, it cannot work because the genarate code only add my real select function, it will be big help to parse package and add it to generated code.
Additional context
i dont know whether if other lang can do this, but because of golang only support package level function ,so do this may be not very hard.
The text was updated successfully, but these errors were encountered: