Skip to content
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

Flag option –write-output (-w) does nothing #21

Open
philoserf opened this issue Oct 27, 2020 · 6 comments · May be fixed by #107
Open

Flag option –write-output (-w) does nothing #21

philoserf opened this issue Oct 27, 2020 · 6 comments · May be fixed by #107
Labels
bug Something isn't working

Comments

@philoserf
Copy link

philoserf commented Oct 27, 2020

Expected: using –write-output files are updated in place
Actual: no files are updated
Reference: https://github.com/segmentio/golines/search?q=writeOutput

@yolken-segment
Copy link
Contributor

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.

@yolken-segment yolken-segment added the question Further information is requested label Oct 28, 2020
@philoserf
Copy link
Author

Here is a gist of golines -l . and golines -l -w --debug . on the projects _fixtures folder

https://gist.github.com/philoserf/0921e7f029bc347b96ec506a14f114ec

@yolken-segment
Copy link
Contributor

yolken-segment commented Oct 28, 2020

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!

@yolken-segment yolken-segment added bug Something isn't working and removed question Further information is requested labels Oct 28, 2020
@philoserf
Copy link
Author

I had thought of -l as in gofmt -l or goimports -l

@hochhaus
Copy link

hochhaus commented May 26, 2022

@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?

@jcoquinn jcoquinn linked a pull request Aug 30, 2023 that will close this issue
@SoTeKie
Copy link

SoTeKie commented Feb 16, 2024

Any updates on this or something actionable I can help with?
This is something that would be nice to fix from my perspective :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants