Skip to content

Commit

Permalink
Addressed Shubham's new comments
Browse files Browse the repository at this point in the history
Signed-off-by: Mohit Pal Singh <[email protected]>
  • Loading branch information
mohitpalsingh committed Jun 23, 2023
1 parent 69f5b56 commit 29b9c8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/standalone/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ func moveFileToPath(filepath string, installLocation string) (string, error) {
p := os.Getenv("PATH")

if !strings.Contains(strings.ToLower(p), strings.ToLower(destDir)) {
utils.SanitizeDir(&destDir)
destDir = utils.SanitizeDir(destDir)
pathCmd := "[System.Environment]::SetEnvironmentVariable('Path',[System.Environment]::GetEnvironmentVariable('Path','user') + '" + fmt.Sprintf(";%s", destDir) + "', 'user')"
_, err := utils.RunCmdAndWait("powershell", pathCmd)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ func FindFileInDir(dirPath, fileName string) (string, error) {
}

// SanitizeDir corrects any syntactical errors in the passed directory.
func SanitizeDir(destDir *string) {
*destDir = strings.Replace(*destDir, "'", "''", -1)
func SanitizeDir(destDir string) string {
correctedDestDir := destDir
correctedDestDir = strings.Replace(correctedDestDir, "'", "''", -1)

Check failure on line 410 in utils/utils.go

View workflow job for this annotation

GitHub Actions / Build linux_amd64 binaries

wrapperFunc: use strings.ReplaceAll method in `strings.Replace(correctedDestDir, "'", "''", -1)` (gocritic)
return correctedDestDir
}

0 comments on commit 29b9c8d

Please sign in to comment.