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
Break down long method chained calls #13
Comments
Hi, thanks for the report. Agreed that that would be a good way to split chained methods in some cases. I'll try to dig in more when I get a chance. |
If you point me in the right direction, happy to look into this further and provide a PR. |
Here's a plot of the AST for the https://github.com/segmentio/golines/blob/master/_fixtures/chained_calls.go example (generated by running golines with the Basically, to change the chaining behavior, we need to update the logic in https://github.com/segmentio/golines/blob/master/shortener.go#L500 to "look ahead" at whether It's a little tricky and definitely not a trivial change, but should be doable. |
Is there any news? |
Hi and thanks for a very nice formatter! :) This is super interesting, I've got the following tx := NewTxLogReader().UseDir(filepath.Dir(fp)).RegisterReader("coinbasepro", coinbasepro.NewTransactionLogReader()).ReadBuffer("coinbasepro", []byte(data)) and it gets formatted to tx := NewTxLogReader().UseDir(
filepath.Dir(fp),
).RegisterReader(
"coinbasepro",
coinbasepro.NewTransactionLogReader(),
).ReadBuffer(
"coinbasepro",
[]byte(data),
) but I really want to have it this way: tx := NewTxLogReader().
UseDir(filepath.Dir(fp)).
RegisterReader("coinbasepro", coinbasepro.NewTransactionLogReader()).
ReadBuffer("coinbasepro", []byte(data)) It seems to preffer to break at open paranthesis instead of dot? Could one have a config option for that? Cheers, |
Ok, I think #28 should help things here. With the example above, I get:
Feel free to give it a spin and add any feedback you have in the pull request. Otherwise, will merge in a few days. |
Hi @yolken-segment and thanks, it works perfectly!! Cheers, |
Fixed by #28. Thanks again for the feedback! |
Best described by an example:
rc.Logger.WithField("FIELD", *someField).Info("Some Very Long Info Here")
could be possibly broken down to:
rc.Logger.
WithField("FIELD", *someField).
Info("Some Very Long Info Here")
OR
rc.
Logger.
WithField("FIELD", *someField).
Info("Some Very Long Info Here")
Formatting is not working, but essentially move the methods chain one per line.
The text was updated successfully, but these errors were encountered: