Open philoserf opened 4 years ago
Hmm, I'm not able to reproduce. Here's an example of running golines -w
against one of the fixtures in this repo:
Benjamins-MacBook-Pro:golines benjamin.yolken$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
Benjamins-MacBook-Pro:golines benjamin.yolken$ ./golines -w _fixtures/field_values.go
Benjamins-MacBook-Pro:golines benjamin.yolken$ git diff
diff --git a/_fixtures/field_values.go b/_fixtures/field_values.go
index 4166157..95c040c 100644
--- a/_fixtures/field_values.go
+++ b/_fixtures/field_values.go
@@ -9,10 +9,18 @@ type MyStruct2 struct {
func TestLongStructFields() {
s := &MyStruct2{
- name: fmt.Sprintf(">>>>>>>>>>>>>>>>>>>>>> %s %s %s", "a really long first argument", "a really long second argument", "a third argument"),
+ name: fmt.Sprintf(
+ ">>>>>>>>>>>>>>>>>>>>>> %s %s %s",
+ "a really long first argument",
+ "a really long second argument",
+ "a third argument",
+ ),
value: "short value",
}
fmt.Println(s)
- s2 := &MyStruct2{name: "this is a really long name, I don't think we can split it up", value: "this is a really long value"}
+ s2 := &MyStruct2{
+ name: "this is a really long name, I don't think we can split it up",
+ value: "this is a really long value",
+ }
}
Can you provide an example of the file(s) that you're running it on? If it helps, you can also get more verbose output from your run by adding a --debug
flag.
Here is a gist of golines -l .
and golines -l -w --debug .
on the projects _fixtures
folder
https://gist.github.com/philoserf/0921e7f029bc347b96ec506a14f114ec
Ahhh, ok, now I see- the -l
conflicts with the -w
. The former is intended as a sort of lightweight dry-run that shows which files would be changed without actually modifying them. It should work as expected if you run it with -w
alone.
I'll update the tool to fail with an error if it detects conflicting output modes. The documentation here could probably also be improved. Thanks for the report!
I had thought of -l
as in gofmt -l
or goimports -l
@yolken-segment Thanks for looking into this issue. We want to use both -l -w
at the same time as is supported upstream by both gofmt
and goimports
. This is helpful from linter scripts which want to both output the list of files which are changed and apply the updates in a single run.
Would you consider support both mode in a single run?
Any updates on this or something actionable I can help with? This is something that would be nice to fix from my perspective :D
Expected: using
–write-output
files are updated in place Actual: no files are updated Reference: https://github.com/segmentio/golines/search?q=writeOutput