michaelb / sniprun

A neovim plugin to run lines/blocs of code (independently of the rest of the file), supporting multiples languages
MIT License
1.43k stars 46 forks source link

go file cant process dot import. #249

Open soluty opened 12 months ago

soluty commented 12 months ago

Describe the bug i use dot report in .go file, it cant work fine.

To Reproduce foo/foo.go content:

func Foo() {
   print(123)
}

main.go content:

import . "foo" 
func main() {
   Foo()
}

then i run SnipRun in line Foo(), and it cant compile fine.

Expected behavior it can process the situation with dot import .

michaelb commented 11 months ago

I can't even make this work outside of sniprun though. Go complains about relative paths not being a thing in module mode, not that I understand what it means...

Do you have a complete example that I could go run example.go (and then try to make work inside sniprun) ?

soluty commented 11 months ago

I can't even make this work outside of sniprun though. Go complains about relative paths not being a thing in module mode, not that I understand what it means...

Do you have a complete example that I could go run example.go (and then try to make work inside sniprun) ?

i am sorry , i just make a mistake. it is in go module.

go.mod

module test
go 1.19

main.go

package main

import . "main/foo"

func main() {
    Foo()
}

foo/foo.go

package foo

import "fmt"

func Foo(){
  fmt.Println("foo")
}

now you can go run main.go, and when i select the line Foo(), i hope this could work, now it will get a compile error.