I’m using <suspenders> for VSCode (thanks <@U02TSJ...
# general
l
I’m using suspenders for VSCode (thanks @wide-midnight-78598!), but recently ran into this error for my
go.mod
(odd because it was working before)
Copy code
packages.Load error: err: exit status 1: stderr: go: updates to go.mod needed, disabled by -mod=readonly; to update it:
	go mod tidy
When I try and run
go mod tidy
as suggested, I get the error:
Copy code
go: finding module for package github.com/myorg/models.v1
The
<http://github.com/myorg/models.v1|github.com/myorg/models.v1>
is a path to our protobuf definitions within the repo. Thoughts? Note, I can run pants cmds, etc outside of VSCode just fine, no issues. I feel like I’ve tried everything but no luck.
w
Whoa, people using it in the field. That’s terrifying. I’ve got like 20 updates queued up whenever I finally free up enough to land them. Are you saying that in the vscode terminal it’s bombing out?
l
Of course, love the effort here! So, it’s not the terminal (_I thin_k), but rather VSCode is requiring I run
go mod tidy
(see screenshot below); the path to my
go.mod
file is known within the IDE. But, running
tidy
on the
go.mod
is really not possible. That is, when I run:
Copy code
go mod tidy
go: finding module for package github.com/astro/o11y/models.v1
It tries to fetch the module
<http://github.com/astro/o11y/model.v1|github.com/astro/o11y/model.v1>
which is defined within the monorepo under
src/proto/o11y/v1
(I did generate the protobuf locally using
pants export-codegen src/proto::
).
@wide-midnight-78598 any thoughts?
w
Not really. I don't know much about Go, and the only thing i can think of is that the vscode paths are incorrect, but I'm sure you've checked all that
l
I did, but let’s assume I’m a newbie to VSCode (not too far off really). What paths should be set for pants?
anyways, let me know if you need any help on the plugin. really want to get this working
w
So, the plugin isn't really related to importing/path checking (yet anyways), so it really shouldn't have any effect. Again, without knowing Go, it's hard to say - but I would have assumed there was a setting in the VSCode Go extension having to do with the linter or analyzer? https://github.com/golang/vscode-go/wiki/features#lint-errors
l
@wide-midnight-78598 I was finally able to get
go mod tidy
to work with my
go.mod
file and the generated
proto
classes using pants within VSCode (outside all worked great). So yeah, it was IDE related (as you pointed out) but also had to make some minor adjustments to allow for code completion, remove errors etc. This might be helpful for others using pants + go + proto with VSCode. I can write down my steps on how I got this all working?
w
For sure! I think on our docs, we might have some references for IDE integration, but it would be nice to capture as much utility as possible. At the very least, even someone searching in Slack
l
Hmm yeah I’ve looked over Setting up an IDE but they can be improved. Let me check my notes and compare over the weekend, then suggest some edits 👍
👍 1
@wide-midnight-78598 ok, so this is how I got things working with proto in VS and fix the
packages.Load
error (as mentioned above): 1. In our
go.mod
file within our go module, we added:
Copy code
require github.com/astro/o11y/models.v1 v0.0.0-00010101000000-000000000000
replace github.com/astro/o11y/models.v1 v0.0.0-00010101000000-000000000000 => path/to/o11y/dist/codegen/src/proto/o11y/v1
2. Under
path/to/o11y/dist/codegen/src/proto/o11y/v1
, we added the following
go.mod
Copy code
module github.com/astro/o11y/models.v1

go 1.21.2
3. Then, we were able to run
go mod tidy
successfully
Any of this helpful?
FYI, we then hit this issue .. which isn’t a great experience
w
@gorgeous-winter-99296 @purple-plastic-57801 @fast-nail-55400 Anyone who has actually used Go before have any ideas/suggestions? Way out of my knowledge-base