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

go/printer: bit operations on multiple lines were not aligned during formatting. #70930

Open
tttoad opened this issue Dec 19, 2024 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@tttoad
Copy link

tttoad commented Dec 19, 2024

gopls version

golang.org/x/tools/gopls v0.17.0
golang.org/x/tools/[email protected] h1:yiwvxZX6lAQzZtJyDhKbGUiCepoGOEVw7E/i31JUcLE=
github.com/BurntSushi/[email protected] h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/exp/[email protected] h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=
golang.org/x/[email protected] h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/[email protected] h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/[email protected] h1:TCDqnvbBsFapViksHcHySl/sW4+rTGNIAoJJesHRuMM=
golang.org/x/[email protected] h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/[email protected] h1:dFDhAo0DFSbmpMYZcvCfIQK9q/wH3fMI8V18Gbcnm9E=
golang.org/x/[email protected] h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
honnef.co/go/[email protected] h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I=
mvdan.cc/[email protected] h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU=
mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.23.4

go env

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE=''
GOENV=''
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='*'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='*'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='*'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='*'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='*'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/sn/5swgsgnd0590drsv3qz933dr0000gp/T/go-build2086004526=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Call format.

func GetCapabilities() uint64 {
	return uint64(
		protobufs.ServerCapabilities_ServerCapabilities_AcceptsStatus |
			protobufs.ServerCapabilities_ServerCapabilities_OffersRemoteConfig |
			protobufs.ServerCapabilities_ServerCapabilities_AcceptsEffectiveConfig |
			protobufs.ServerCapabilities_ServerCapabilities_OffersPackages |
			protobufs.ServerCapabilities_ServerCapabilities_AcceptsPackagesStatus |
			protobufs.ServerCapabilities_ServerCapabilities_AcceptsConnectionSettingsRequest,
	)
}

What did you see happen?

func GetCapabilities() uint64 {
	return uint64(
		protobufs.ServerCapabilities_ServerCapabilities_AcceptsStatus |
			protobufs.ServerCapabilities_ServerCapabilities_OffersRemoteConfig |
			protobufs.ServerCapabilities_ServerCapabilities_AcceptsEffectiveConfig |
			protobufs.ServerCapabilities_ServerCapabilities_OffersPackages |
			protobufs.ServerCapabilities_ServerCapabilities_AcceptsPackagesStatus |
			protobufs.ServerCapabilities_ServerCapabilities_AcceptsConnectionSettingsRequest,
	)
}

What did you expect to see?

func GetCapabilities() uint64 {
	return uint64(
		protobufs.ServerCapabilities_ServerCapabilities_AcceptsStatus |
		protobufs.ServerCapabilities_ServerCapabilities_OffersRemoteConfig |
		protobufs.ServerCapabilities_ServerCapabilities_AcceptsEffectiveConfig |
		protobufs.ServerCapabilities_ServerCapabilities_OffersPackages |
		protobufs.ServerCapabilities_ServerCapabilities_AcceptsPackagesStatus |
		protobufs.ServerCapabilities_ServerCapabilities_AcceptsConnectionSettingsRequest,
	)
}

We should be support Split parameters into separate lines and Join parameters into one line.

Editor and settings

No response

Logs

No response

@tttoad tttoad added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Dec 19, 2024
@gopherbot gopherbot added this to the Unreleased milestone Dec 19, 2024
@mateusz834 mateusz834 changed the title x/tools/gopls: bit operations on multiple lines were not aligned during formatting. go/printer: bit operations on multiple lines were not aligned during formatting. Dec 19, 2024
@mateusz834 mateusz834 added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Dec 19, 2024
@zigo101
Copy link

zigo101 commented Dec 21, 2024

Maybe the current formatting is not very bad. In fact, it is good when the bit operation is used as one argument among several.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants