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

delete and recreate go.mod instead of running go mod tidy #2948

Merged
merged 2 commits into from
Dec 23, 2019
Merged

delete and recreate go.mod instead of running go mod tidy #2948

merged 2 commits into from
Dec 23, 2019

Conversation

stamblerre
Copy link
Contributor

Running go mod tidy is more error-prone than just deleting and recreating the file.

Fixes #2936.

@@ -148,16 +144,19 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise<voi
envForTools['GO111MODULE'] = 'on';
}

// Write a temporary go.mod file. This shouldn't affect anything if we've explicitly disabled modules.
const tmpGoModFile = path.join(toolsTmpDir, 'go.mod');
fs.writeFileSync(tmpGoModFile, 'module tools');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this, we are creating a new go.mod file for each tool being installed right?
In that case, should we move it inside the else block of the if (modulesOffForTool) check a few lines above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, did you check if fs.writeFileSync fails gracefully if the file already exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't matter if we write the file even if modules are off, but I moved the check in case. fs.writeFileSync replaces the file if it already exists.

@ramya-rao-a ramya-rao-a merged commit da2c54c into microsoft:master Dec 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gotests fails to be installed
2 participants