MordFustang21 / ide-gopls

Atom integration with the Go language server (gopls)
MIT License
13 stars 5 forks source link

Doesn't work with non-root go.mod #10

Open Zaba505 opened 4 years ago

Zaba505 commented 4 years ago

First, I'd like to say thanks for putting this together! I really enjoy using it for all my Go projects but I have discovered an issue when I have a non-root go.mod. For example, let's say the given structure of a project is:

/my-project
  /cmd
    /my-awesome-tool
      go.mod
      main.go

Currently, if I open on the main.go file inside my-awesome-tool the following message appears:

You are neither in a module nor in your GOPATH. Please see https://github.com/golang/go/wiki/Modules for information on how to set up your Go project.

Go (gopls) /my-project/

Not sure if this is an issue with ide-gopls or gopls itself but I figured I'd start here and see if anyone else has ran into the same problem.

stamblerre commented 4 years ago

Thanks for the report! This is a gopls issue that we're working to resolve for gopls/v0.5.0.

Zaba505 commented 4 years ago

@stamblerre Thanks for replying so fast and sorry the late response. I was glancing through the issues for gopls and I couldn't find anything that mentions this explicitly. Just wondering if you have a issue to link to in order to watch its progress?

stamblerre commented 4 years ago

No problem! The issue for the warning is https://github.com/golang/go/issues/37279, and a number of the issues related to the workspace management are actually now in the gopls/v0.6.0 milestone: https://github.com/golang/go/milestone/139.

Zaba505 commented 4 years ago

Looking at golang/go#32394 I came across this your comment about adding a Workspace folder for each module. I think this is a good band-aid till gopls handles multiple modules automatically. Unfortunatelly, I can't find anything about configuring workspaces through ide-gopls. Do you think it's worth implementing this in ide-gopls or waiting for gopls/v0.6.0?

stamblerre commented 4 years ago

The workspace folders are typically handled at the level of the editor (for example, in VS Code, you can add a folder to a workspace via File -> Add Folder to Workspace). I am not sure if Atom has this same support (https://blog.atom.io/2015/04/15/multi-folder-projects.html looks promising), so it may just work out of the box. Otherwise, I'd say that if it's easy to implement in ide-gopls, it may be worth it, but if it's a significant undertaking, it'd probably be best to wait for gopls/v0.6.0.

Zaba505 commented 4 years ago

Thanks for the feedback! I'm gonna look into implementing it later this week when I have some time. I broke workspace configuration into its own issue, #11