-
Notifications
You must be signed in to change notification settings - Fork 645
Fix internal package import #1535
Fix internal package import #1535
Conversation
@ramya-rao-a please check |
@ramya-rao-a maybe it's a good idea to add unit tests for this project, test that doesn't rely to UI, and relatively fast to run. Haven't figure out how to do it in this project, the idea to separate the test command.
not sure which follows best practice |
src/goPackages.ts
Outdated
@@ -238,7 +238,7 @@ export function isAllowToImportPackage(toDirPath: string, currentWorkspace: stri | |||
let internalPkgFound = pkgPath.match(/\/internal\/|\/internal$/); | |||
if (internalPkgFound) { | |||
let rootProjectForInternalPkg = path.join(currentWorkspace, pkgPath.substr(0, internalPkgFound.index)); | |||
return toDirPath.startsWith(rootProjectForInternalPkg); | |||
return toDirPath.startsWith(rootProjectForInternalPkg + '/') || toDirPath === rootProjectForInternalPkg; |
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.
Any chance in Windows this would be \
instead?
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.
Not sure... it based on pkg. It will fail on let internalPkgFound = pkgPath.match(/\/internal\/|\/internal$/);
also..
Need Windows machine
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.
I see.. will push latest changes
Refactoring this project for tests has been one thing that I wanted to do for a long time. Having tests that do not rely on the extension host spinning up a new window will definitely help. I am not sure how to go about that at the moment, but I'll give that a try soon |
Awesome 👍 |
This fix is now available in the latest update (0.6.78) to the Go extension |
Fixes for case:
package to import:
github.com/uudashr/myproject/internal/config'
importer package:
/Users/uudashr/go/src/github.com/uudashr/myproject-monitoring/cmd/app-monitor
Expect: Shouldn't allowed