Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Disallow import internal root package (#1681)
Browse files Browse the repository at this point in the history
* Disallow internal package on root

* Fix the regex for detecting internal package

* Disallow to use internal package located on root
  • Loading branch information
uudashr authored and ramya-rao-a committed Jun 4, 2018
1 parent 5bc4ce4 commit 1d48333
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/goPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ export function getNonVendorPackages(folderPath: string): Promise<string[]> {
// see: https://golang.org/doc/go1.4#internalpackages
// see: https://golang.org/s/go14internal
function isAllowToImportPackage(toDirPath: string, currentWorkspace: string, pkgPath: string) {
if (pkgPath.startsWith('internal/')) {
return false;
}

let internalPkgFound = pkgPath.match(/\/internal\/|\/internal$/);
if (internalPkgFound) {
let rootProjectForInternalPkg = path.join(currentWorkspace, pkgPath.substr(0, internalPkgFound.index));
Expand Down

0 comments on commit 1d48333

Please sign in to comment.