Skip to content

feat: remove warning when the config file is explicitly stdin #3740

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

Merged
merged 2 commits into from
Mar 29, 2023

Conversation

ldez
Copy link
Member

@ldez ldez commented Mar 27, 2023

Fixes #3739

@ldez ldez added enhancement New feature or improvement area: config Related to .golangci.yml and/or cli options topic: cosmetic changes contain cosmetic improvements labels Mar 27, 2023
@ldez ldez marked this pull request as draft March 27, 2023 23:25
@ldez ldez marked this pull request as ready for review March 27, 2023 23:29
@ldez ldez force-pushed the fix/sdtin-remove-warning branch from caa8050 to 97474a1 Compare March 28, 2023 00:04
Copy link
Member

@bombsimon bombsimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this change only removes the warning but if we want to support this, would it make sense to detect content on stdin and automatically use that instead of having to pipe stdin to -c/--config? I was thinking something like

stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 {
	// Got data on stdin
} else {
	// Use flag or default config
}

Approving this either way since a change like that probably deserves its own PR.

@ldez
Copy link
Member Author

ldez commented Mar 28, 2023

I know this change only removes the warning but if we want to support this, would it make sense to detect content on stdin and automatically use that instead of having to pipe stdin to -c/--config? I was thinking something like

stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 {
	// Got data on stdin
} else {
	// Use flag or default config
}

I already think about that but this only detects if the command is piped and not if the configuration comes from stdin.
A pipe can be used in different contexts and not only for the configuration file.

@ldez ldez force-pushed the fix/sdtin-remove-warning branch from 97474a1 to 99c7a1d Compare March 28, 2023 20:07
@ldez ldez merged commit ca05239 into golangci:master Mar 29, 2023
@ldez ldez deleted the fix/sdtin-remove-warning branch March 29, 2023 06:51
SeigeC pushed a commit to SeigeC/golangci-lint that referenced this pull request Apr 4, 2023
@ldez ldez added this to the v1.53 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: config Related to .golangci.yml and/or cli options enhancement New feature or improvement topic: cosmetic changes contain cosmetic improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support reading configuration from stdin
2 participants