-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: follows symbolic links with formatter exclusion paths #6180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
'ln -s worktree wt && cd wt && golangci-lint fmt' now works Signed-off-by: David L. Chandler <[email protected]>
|
Hey, thank you for opening your first Pull Request ! |
e7aa83f to
f467aa2
Compare
|
The problem supposedly fixed by this PR "issue with the 'fmt' command and symbolic links" is not fixed. At first, I was thinking the PR title was wrong because the only change was in the exclusions system. But in fact, this PR fixes nothing, because the problem with symlinks is not here. This is why it's better to open an issue before opening a PR, and when opening a PR, a real description is important. I close this PR, and I will try to create the real fix. |
This is how to reproduce, on MacOS 15.7.1, with golangci-lint 2.6.1. You can work around the issue with This has nothing to do with formatter exclusion paths. My test case fails on |
|
Your commit is only modifying
golangci-lint/pkg/goformat/runner.go Lines 236 to 244 in 7bcb236
golangci-lint/pkg/goformat/runner.go Lines 250 to 252 in 7bcb236
golangci-lint/pkg/fsutils/basepath.go Lines 56 to 57 in 7bcb236
A concrete reproducer#!/bin/sh -e
ROOT=$(mktemp -d)
mkdir -p $ROOT/project/
## Create module
cat > $ROOT/project/go.mod <<EOF
module github.com/golangci/sandbox
go1.24.0
EOF
# Create golangci-lint configuration file.
cat > $ROOT/project/.golangci.yaml <<EOF
version: "2"
formatters:
enable:
- gofmt
EOF
## Create main.go file.
cat > $ROOT/project/main.go <<EOF
package main
import "fmt"
func main() {
fmt.Println("hello world") // Formatting problem.
}
EOF
## Create symlink to the project directory.
ln -s $ROOT/project/ $ROOT/workdir
## Run golangci-lint inside the real project directory.
cd $ROOT/project
echo
echo "--------------------------"
echo "Run on the real project directory ($(pwd)):"
echo
golangci-lint fmt --diff || true
## Run golangci-lint inside the symlinked project directory.
cd $ROOT/workdir
echo
echo "--------------------------"
echo "Run on the symlinked project directory ($(pwd)):"
echo
golangci-lint fmt --diff || true
rm -rf $ROOT$ ./setup.sh
--------------------------
Run on the real project directory (/tmp/tmp.5C7AJyRYRC/project):
diff /tmp/tmp.5C7AJyRYRC/project/main.go.orig /tmp/tmp.5C7AJyRYRC/project/main.go
--- /tmp/tmp.5C7AJyRYRC/project/main.go.orig
+++ /tmp/tmp.5C7AJyRYRC/project/main.go
@@ -3,5 +3,5 @@
import "fmt"
func main() {
-fmt.Println("hello world") // Formatting problem.
+ fmt.Println("hello world") // Formatting problem.
}
--------------------------
Run on the symlinked project directory (/tmp/tmp.5C7AJyRYRC/workdir):
$I will create a PR with the real fix. |
|
That is the perfect reproducer. I'll open an issue next time with a real reproducer. |
ln -s worktree wt && cd wt && golangci-lint fmtnow works