Open jmhodges opened 5 years ago
Relevant code in bazel_gomock: https://github.com/jmhodges/bazel_gomock/blob/master/gomock.bzl#L9-L12
I guess a more general question is: how do we translate a random source file that we know is in a given GoLibrary into its go_path equivalent (in order to avoid go module network connections)?
(The patch to avoid that go module network stuff was given to me by another user, so perhaps the real general question is there a way for rules_go to help us out with avoiding go module related network connections?)
Hm, I hacked this up with
args = ["-source", gopath + "/src/" + ctx.attr.library[GoLibrary].importmap + "/"+ ctx.file.source.basename]
I think that basename call will work consistently because of how gopath would require the source code to be immediately in the same directory as its importmap.
So if I understand correctly, you have a GoPath
, a GoLibrary
, and a source file, and you need to know the path of the file within the directory constructed by go_path
?
Your last comment looks correct based on how go_path
works today. It's unfortunate that importmap
needs to be used instead of importpath
-- I think that was needed to accomodate multiple vendored copies of the same package, though it's been a long time since I looked through that code.
Ah, I never answered here.
I was thinking that, yep, I needed the source path inside of gopath in order to avoid various tools from complaining about working outside of GOPATH
This is with HEAD and bazel 0.28.1.
bazel_gomock with the
source
parameter (which is the set to the target of a specific file in a user's project) is no longer working. It seems that where, previously, the source code for your project would be atgopath + ctx.file.source.path
, it's now atgopath + repo_prefix + ctx.file.source.path
(whererepo_prefix
seems to be the import path of the prefix?)I couldn't find the repo prefix (import path, whatever) in the GoContext API. Where is it at?