xxpxxxxp / intellij-plugin-golangci-lint

GolangCI-Lint integration for IDEA
GNU General Public License v3.0
223 stars 14 forks source link

don't follow symlinks in "path to golangci-lint" option #138

Closed ghost closed 1 year ago

ghost commented 1 year ago

Summary

Today, when you select a path to golangci-lint, it follows the symlink if it is one (at least on the Mac). For example, I have golangci-lint installed via brew, so I have:

/opt/homebrew/Cellar/golangci-lint/1.52.2/bin/golangci-lint  # executable
/opt/homebrew/var/homebrew/linked/golangci-lint -> ../../../Cellar/golangci-lint/1.52.2 # symlink

Today:

This means that as soon as I run brew upgrade golangci-lint, the config is broken (because brew will delete the old version after it creates the new one). I really did want the path to be /opt/homebrew/var/homebrew/linked/golangci-lint, which always points to the latest.

Workaround

  1. Temporarily create a non-symlinked executable at /opt/homebrew/var/homebrew/linked/golangci-lint:
    cd /opt/homebrew/var/homebrew/linked/
    mv golangci-lint golangci-lint.bak
    mkdir -p golangci-lint/bin
    cp golangci-lint.bak/bin/golangci-lint golangci-lint/bin/
  2. Set the path in the intellij config for the Go Linter plugin
  3. Remove the temporary executable:
    cd /opt/homebrew/var/homebrew/linked/  # same as before
    rm golangci-lint.bak/bin/golangci-lint  # I hesitate to use "rm -rf" in brew's dirs!
    rmdir golangci-lint/bin
    rmdir golangci-lint
    mv golangci-lint.bak golangci-lint

It looks like the symlink resolution only happens when you select the file (not during Intellij's startup, for example), so this does stick to the symlink itself (as I wanted).

Versions info

xxpxxxxp commented 1 year ago

thanks for report, that's a reasonable request, I'll fix it soon.

ghost commented 1 year ago

I just saw that you updated the plugin, with this change. I tried it locally and it worked perfectly. Thanks so much for the exceptionally fast turnaround! :)