-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 Add go.work to .gitignore and .dockerignore #8155
Conversation
I wonder how folks were developing with vscode in the past. Maybe there's a way to configure vscode? In intellij everything just works and I'm hesitant to use go workspaces just for vscode. (I'm not sure what the implications for go.mod/go.sum are if we start using go workspaces) |
I mostly add a go.work file but do not check it in into git ... (comes with the cons of maybe not all make targets will work anymore) |
Sure, I'd be happy to hear what others have been doing to get VSCode working. I figured that if everyone was using this same solution, it'd make sense to make it a common file instead of having an additional step to configure it every time you clone the repo. |
Not sure, but looks like it breaks our e2e test |
Interestingly, i see a few places saying that the |
Let's see how other folks are using it. Might be an alternative to:
|
cc @vincepri @ykakarap @fabriziopandini How are you dealing with this when you're using VSCode for CAPI? |
Hmm if we don't want to commit the file maybe we can add a Makefile target that inits the go.work file and sets it up. Will adding it to Dockerignore be enough to make it not break the |
Worked on my machine |
39950e9
to
b162280
Compare
@sbueringer I made some changes to add the make targets, lmk how that works for you! |
/retest |
Makefile
Outdated
@@ -798,6 +799,11 @@ kind-cluster: ## Create a new kind cluster designed for development with Tilt | |||
tilt-up: kind-cluster ## Start tilt and build kind cluster if needed. | |||
tilt up | |||
|
|||
.PHONY: go-work | |||
go-work: ## Generate go.work and go.work.sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's a good idea to add it to the ignore files but I don't think the make targets are useful unless there's clear guidance on how to use workspaces for CAPI dev.
Could we just include the .gitignore and .dockerignore until we have some best practices?
I like the idea of the make target, this is helpful 👍 And with the entries in the ignore files. /lgtm |
LGTM label has been added. Git tree hash: 656c36930ba51f2fff7f915b4bfdf00c83e38a38
|
I'm not sure what problem putting go.work files at the top-level in the CAPI repo is solving, so I wouldn't include them in the Makefile without a clear picture of that. Inspired by this (thanks @Jont828!) I've been playing around with workspaces to solve #6081. I think what we'd want in CAPI is workspaces where we currently have modules with |
I think having
What the top-level go.work file solves is: The used go language server |
@killianmuldoon - its solving the problem where vscode complains about editing a nested package: |
Thanks for the explanation @chrischdi - was really helpful 🙂. And thanks for the error message @richardcase. I think I'll let others have their say, but I'm fine with this with or without the make targets. |
Can we follow the pattern introduced in #8088 instead of creating a make target? We already have so many make targets and they are usually used for our daily work and not a for a "once-in-a-lifetime" operation like creating a go.work file for VSCode users. |
@sbueringer @killianmuldoon I think the main thing is that we need to generate the go.work file instead of it being like a template you can copy/paste. I figured we could add something so folks wouldn't have to figure which how to set up the
|
Why does it have to be generated? I'm probably wrong but it looked pretty static to me |
I'm not sure, we're just expected in the docs to init the file, probably because it has a go.work.sum file along with it. |
Ah I see. Yeah we can't check in the go.work.sum file. Independent of that I think it would be better if we would document dev/IDE setup in the book and mention there that folks should run those two commands. I don't think a lot of folks will just find this make target. And also as mentioned above it seems like this is only ever run once. So overall I don't think a Make target is a good way to document this for contributors. Maybe we can merge this PR with only the ignore files and then create a follow-up issue to introduce a dedicated dev/IDE setup page in the book where we can mention that? |
Sorry, for getting to this discussion late |
@fabriziopandini I think that would make sense as well since it's an official feature as you said. The only thing is that the some of the make targets for build and e2e tests don't work with the go.work file. I don't know if that's supposed to happen or if we'd need to make an additional change. |
There's ongoing discussion at the go repo about this - golang/go#53502. My inclination is not to include it unless there's some clear benefit. I agree with @sbueringer that this is better in a doc than in a readme - now that we have a It would be good to drop the make target from this PR and move broader discussion about CAPI using workspaces to an issue. |
@killianmuldoon @sbueringer I've went ahead and dropped this from the make targets. I think we can merge this so it'll work with the .gitignore and .dockerignore for now. WDYT? |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbueringer The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM label has been added. Git tree hash: 8cbe3d45e8c722d02ac058d9546aa6bc12814170
|
/area devtools |
What this PR does / why we need it: VSCode doesn't support nested modules like
test/infrastructure/docker
and will not give autocomplete or linting suggestions. Adding a go.work file allows VSCode to recognize the nested modules.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #