-
Notifications
You must be signed in to change notification settings - Fork 66
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
automatically detect Go module path #31
base: master
Are you sure you want to change the base?
Conversation
beaf80d
to
dd4d414
Compare
Hey guys! @dmke would you be interested into updating this PR? Also @daixiang0 what is your take here? If you don't mind me asking! I'm working with a monorepo with multiple modules, and this feature would make my life simpler! |
@victoraugustolls Interested sure, but I'm currently in short supply of free time :) It might take me until the weekend before I get to update the PR. Looking at #43, this might not be a trivial task... |
This is an useful feature I think :) |
Thanks for your contribution, now it has changed a lot. I will review if you update it. |
This started as a proof-of-concept for daixiang0#30. Signed-off-by: Dominik Menke <[email protected]>
I've updated the code, however I can't get it to work: At some point, I think a better way to pass the module path is to add an appropriate field to Looking at $ cat ../whatever.go | gci diff -s Standard,Module,Default
$ gci diff -s Standard,Module,Default ../whatever.go |
for path := range knownModulePaths { | ||
modulePaths = append(modulePaths, path) | ||
} | ||
moduleSection.SetModulePaths(modulePaths) |
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.
This doesn't work, moduleSection
is a pointer to a copy of g.Section[i]
.
I think this feature is helpful for a project, we can detect from Maybe we can skip single file support for now, until we get a better solution. |
Feel free to take my code and make it work. I currently am quite busy with other things, and don't know when I gain the mental capacity needed to complete this... |
I usually call gci using file watcher from the root of the project, indicating the full path to the file. Therefore, I think that you can try to look for the go.mod file in the current folder (where the utility is called) and if found, use it to determine the name of the module |
Thanks for your work! I've created #179 that is a slimmed-down version of this work: it just handles looking at |
This is just a proof of concept for #30.