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

golines does not shorten index expressions in declarations #128

Open
bgimby opened this issue May 15, 2024 · 1 comment · May be fixed by #129
Open

golines does not shorten index expressions in declarations #128

bgimby opened this issue May 15, 2024 · 1 comment · May be fixed by #129

Comments

@bgimby
Copy link

bgimby commented May 15, 2024

golines will shorten a declaration like this:

foo := longlistfunc(bigarg, otherbigarg, verylongarg, veryverylongarg, veryveryverylongarg, extremelylongarg)

to

foo := longlistfunc(
	bigarg,
	otherbigarg,
	verylongarg,
	veryverylongarg,
	veryveryverylongarg,
	extremelylongarg,
)

I would expect it to similarly shorten a declaration like

foo := longlistfunc(bigarg, otherbigarg, verylongarg, veryverylongarg, veryveryverylongarg, extremelylongarg)[0]

to

foo := longlistfunc(
	bigarg,
	otherbigarg,
	verylongarg,
	veryverylongarg,
	veryveryverylongarg,
	extremelylongarg,
)[0]

but it is left alone. This appears to be due to formatExpr not supporting index expressions. It results in a debug message like

Got an expression type that can't be shortened: *dst.IndexExpr
@bgimby bgimby linked a pull request May 15, 2024 that will close this issue
@mlschechter
Copy link

Also seeing this bug; it's very confusing, and causing issues with the use of the golangci-lint linter lll.

@yolken-segment - Is there anything preventing a fix for this issue from moving forward?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants