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

Go (Gogland) support #61

Closed
mwitkow opened this issue Feb 28, 2017 · 23 comments
Closed

Go (Gogland) support #61

mwitkow opened this issue Feb 28, 2017 · 23 comments

Comments

@mwitkow
Copy link

mwitkow commented Feb 28, 2017

We're currently moving our monorepo to Bazel, and the last dangling bit is:
https://github.com/bazelbuild/rules_go
We really enjoy Gogland and would love to have it nicely integrated with Bazel.

Is the custom skylark rule support in? If so, how would it work with the current Go plugin? @ignatov and @zolotov for context, as they're the main Golang Plugin developer.

@zolotov
Copy link

zolotov commented Feb 28, 2017

We're open to collaboration and we can provide any extension points that might be needed for integration.

As I can see, integrating Bazel with Gogland won't be a hard task, the only thing that Gogland should know from Bazel is where SDK and libraries can be found.

I took a look at the code. Unfortunately, we're going to get rid of using Java-specific libraries in Gogland and Go plugin, so looking for Go SDK- and GOPATH- prefixed libraries won't work anymore.

@mwitkow
Copy link
Author

mwitkow commented Feb 28, 2017

@ains and @yifanzz for context

@brendandouglas
Copy link
Contributor

Custom skylark support is not in yet, but we're working on it.

We weren't planning to provide Gogland IDE support (see #37), but I believe JetBrains is planning to release a basically-equivalent IntelliJ UE plugin (similar to the PyCharm setup). Is that correct @zolotov?

If so, we're definitely interested in integrating with the Go plugin. Are there any plans for facet support in the Go plugin? (rather than requiring the project SDK be a Go SDK)

@zolotov
Copy link

zolotov commented Feb 28, 2017

Yes, there will be the Go plugin for IntelliJ Ultimate.

Why not support Gogland IDE? I didn't find the answer in #37. It's just the very same code as for plugin supporting. Please contact me if you have any technical issues on supporting different IDEs.

No, we're not going to introduce facets and the plugin doesn't require project SDK either. Instead, there will be a Gogland-specific project settings storage that will contain GOPATH and GOROOT settings.

@brendandouglas
Copy link
Contributor

No technical problems supporting Gogland beyond the additional maintenance -- supporting only three products (IntelliJ Community, IntelliJ Ultimate, and CLion) significantly reduces our maintenance burden. So we try to encourage internal users to use IntelliJ UE rather than Webstorm, PyCharm, etc., in cases where the standalone IDE is a functional subset.

We'll certainly reconsider if there's demand for Gogland-specific support though.

@narqo
Copy link

narqo commented May 6, 2017

Having no possibility to use bazel with Goglang is really sad. Currently, there is seems no any integrated build tools that could be used inside the IDE to build a complex project that doesn't feet into simple go build pipe.

@mwitkow
Copy link
Author

mwitkow commented May 8, 2017

What we do internally is we have a hack that code-generate a set of symlinks that we use as GOPATH out of bazel-bin and bazel-out. @ains can probably shed a little light here. However, this is a really really bad hack.

What's more, you can't even load the Bazel plugin into Gogland as it is complaining about lacking Java-specific dependencies. Would love to at least use the plugin for editing BUILD files.

@gfernandessc
Copy link

Are there more concrete plans for Go support on the plugin? The dependencies are not being imported properly in Intellij UE when using both the bazel plugin and the Go plugin.

@brendandouglas
Copy link
Contributor

We have no concrete date for Go support, but it is something we'll definitely get to at some point.

@hsyed
Copy link

hsyed commented Oct 14, 2017

@brendandouglas could we get some documentation on how to configure the go support. I can't figure out how to set the goroot, and only code in the GOPATH is picked up (not vendored directories).

@brendandouglas
Copy link
Contributor

Go support is extremely rudimentary at the moment. It's something we're currently working on.

When that's done, if it turns out there are manual set up steps required, we'll add them to the documentation.

@brendandouglas
Copy link
Contributor

The latest release should have much-improved Go support, and GOPATH / import resolution should all be set up automatically as part of the Bazel sync action.

Closing this general issue, but please open separate issues for specific problems with Go support.

@promiseofcake
Copy link

I think the original issue is geared towards the fact that Gogland (now Goland) does now allow the installation of the IntelliJ plugin due to the IDE's missing Java dependencies.

@brendandouglas
Copy link
Contributor

Yes, we don't build the plugin for Goland, but instead support using the Goland plugin in IntelliJ UE.

This has all the same features as Goland itself, but isn't specific to Go.

@brendandouglas
Copy link
Contributor

The Bazel plugin should now be available for Goland, as of the latest release

@tdarci
Copy link

tdarci commented Apr 27, 2018

Very happy to have the Bazel plugin available for GoLand... though it fails to initialize. Getting "Bazel plugin dependencies are missing": "The JUnit plugin is disabled, but it's required for the Bazel plugin to function. Please enable the JUnit plugin and restart the IDE"

Unfortunately, there is no JUnit plugin for GoLand.

This is GoLand 2018.1.2 and Bazel Plugin 2018.01.02.0.1. On Mac that also has IntelliJ IDEA Ultimate installed.

Failure seems to be in initComponent() here: https://github.com/bazelbuild/intellij/blob/d5e4e5073473a4a66d869d40743a08f8846063d5/java/src/com/google/idea/blaze/java/plugin/JUnitPluginDependencyWarning.java

Any info/guidance much appreciated.

thanks,
td

@promiseofcake
Copy link

@tdarci, I think it's currently only supported for the 2017.x releases as of the latest plugin release.

@mennanov
Copy link

@mwitkow , @ains you mentioned that

What we do internally is we have a hack that code-generate a set of symlinks that we use as GOPATH out of bazel-bin and bazel-out. @ains can probably shed a little light here. However, this is a really really bad hack.

Could you, please, share the details?

Unfortunately i could not make the plugin work with the most recent Intellij or GoLand. It only works for me in Intellij 2017.3 but its Go integration is not as nice as i expected:
screen shot 2018-10-11 at 17 53 05

so it fails to resolve local imports (and also some non-local), however everything builds and runs (tests) fine in Bazel.

@chaoren
Copy link
Collaborator

chaoren commented Oct 12, 2018

The open source rules_go implementation has different providers from what blaze has internally, and we can't access them without a hard dependency on rules_go from our aspect. Until that issue is resolved, we won't be able to resolve test and protobuf sources.

@mennanov
Copy link

Given the popularity of rules_go externally would it make sense to add them to //third_party/golang and make Blaze be aware of it?

@chaoren
Copy link
Collaborator

chaoren commented Oct 13, 2018

It needs to be exactly the same copy that the user is loading into their project. We can't ask all of our users to load rules_go.

@mennanov
Copy link

@chaoren , is there any workaround for this problem?
Can i manually add the locations of the generated *.pb.go files to $GOPATH in GoLand settings? If yes, how can i do that properly?

As i've tried different approaches and neither of them worked.
For example consider the following code:

import "github.com/mennanov/scalemate/accounts/proto/accounts"

The generated *.pb.go files (produced by the go_proto_library rule) are located here:

/Users/renat/go-paths [renat@renat] [14:19]
> tree /Users/renat/go/src/github.com/mennanov/scalemate/bazel-bin/accounts/proto/darwin_amd64_stripped/accounts_go_proto%/github.com
/Users/renat/go/src/github.com/mennanov/scalemate/bazel-bin/accounts/proto/darwin_amd64_stripped/accounts_go_proto%/github.com
└── mennanov
    └── scalemate
        └── accounts
            └── proto
                ├── accounts
                │   ├── accounts.pb.go
                │   └── accounts.validator.pb.go
                └── accounts.a

I created a separate folder to mimic a GOPATH and added it to the GoLand GOPATH settings:

/Users/renat/go-paths [renat@renat] [14:19]
> tree
.
└── scalemate-accounts-proto
    ├── pkg
    └── src
        └── github.com -> /Users/renat/go/src/github.com/mennanov/scalemate/bazel-bin/accounts/proto/darwin_amd64_stripped/accounts_go_proto%/github.com

But GoLand is still unable to resolve this import.

@mennanov
Copy link

mennanov commented Oct 24, 2018

$GOPATH seems to be ignored by GoLand when the Bazel intellij plugin is activated.

I've finally come up with an ugly hack: created symlinks in the same directory where the .proto files are to the generated *.pb.go files and added a separate go_library rule:

# gazelle:exclude accounts.pb.go
# gazelle:exclude accounts.validator.pb.go
go_library(
    name = "go_proto_hack",
    srcs = [
        "accounts.pb.go",
        "accounts.validator.pb.go"
    ],
    importpath = "github.com/mennanov/scalemate/accounts/accounts_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//shared/proto:go_default_library",
        "@org_golang_google_grpc//:go_default_library",
        "@com_github_golang_protobuf//proto:go_default_library",
        "@com_github_mwitkow_go_proto_validators//:go_default_library",
        "@io_bazel_rules_go//proto/wkt:empty_go_proto",
        "@io_bazel_rules_go//proto/wkt:field_mask_go_proto",
        "@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
        "@org_golang_x_net//context:go_default_library",
    ],
)

Without having this go_library rule I got build constraints exclude all Go files in '' error message at the import path even though the files were physically presented in this directory.

UPD: actually, there is a better solution #194 (comment)

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

10 participants