Skip to content

feat: add --ignore-func-signatures flag to prevent wrapping function signatures#32

Open
danrneal wants to merge 1 commit intogolangci:mainfrom
danrneal:feature/ignore-func-signatures
Open

feat: add --ignore-func-signatures flag to prevent wrapping function signatures#32
danrneal wants to merge 1 commit intogolangci:mainfrom
danrneal:feature/ignore-func-signatures

Conversation

@danrneal
Copy link
Copy Markdown

Addresses Discussion #31

Description

This PR introduces a new boolean flag, --ignore-func-signatures, which allows users to bypass the line-shortening logic specifically for function declarations and function types.

By default, golines applies the --max-len limit uniformly across all AST nodes, which can force function signatures with multiple parameters to wrap across several lines. The Go standard library frequently keeps function signatures on a single line even when they exceed typical column limits (e.g., in image/draw).

This flag gives users the option to strictly format the bodies of their functions and structs to a specific length while maintaining idiomatic, single-line function signatures, eliminating the need to rely on //golines:ignore comments above every long signature.

Changes Made

  • Added the --ignore-func-signatures boolean flag (default: false) to the CLI.
  • Threaded the new configuration option through shorten.Config.
  • Updated formatDecl (*dst.FuncDecl) and formatExpr (*dst.FuncType) in shorten/format.go to conditionally bypass formatting the parameter list if the flag is enabled.
  • Added a new E2E test case in shorten/testdata/ignore_func_signatures to verify the behavior.
  • Updated README.md with documentation for the new flag.

@danrneal danrneal force-pushed the feature/ignore-func-signatures branch from a4738ba to ec32158 Compare April 15, 2026 04:36
This adds a boolean flag, `--ignore-func-signatures`, which allows users to bypass shortening logic for function declarations and types. This enables keeping function signatures with many parameters on a single line, adhering more closely to standard library idioms where signatures often exceed global line length limits.
@danrneal danrneal force-pushed the feature/ignore-func-signatures branch from ec32158 to 6a2ee9e Compare April 15, 2026 04:38
@ldez ldez self-requested a review April 15, 2026 17:51
@ldez ldez added the enhancement New feature or request label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants