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

Set stderr and stdout explicitly #1932

Closed
wants to merge 1 commit into from

Conversation

kamilsk
Copy link
Contributor

@kamilsk kamilsk commented Apr 25, 2021

Related to: #1869

Motivation: the patch uses stdout implicitly and affects testability.

Tested:

$ go run ./cmd/golangci-lint/ version 2>/dev/null
golangci-lint has version (devel) built from (unknown, mod sum: "") on (unknown)
$ go run ./cmd/golangci-lint/ version 1>/dev/null

@kamilsk
Copy link
Contributor Author

kamilsk commented Apr 25, 2021

I think that only main function should decide what input/output it uses. For example: https://github.com/octomation/go-tool/blob/271d0b52b43c560e24c2e66615a2d1c49347a1a3/main.go#L42-L43

It will require a bit more editing, but I can do it if needed.

@ldez
Copy link
Member

ldez commented Apr 25, 2021

What is the problem that solves this PR? 🤔

@ldez ldez added the feedback required Requires additional feedback label Apr 25, 2021
@kamilsk
Copy link
Contributor Author

kamilsk commented Apr 25, 2021

It solves the original problem #1868 but uses an explicit approach instead of implicit.

@kamilsk
Copy link
Contributor Author

kamilsk commented Apr 25, 2021

I suggest to restore the original code (revert https://github.com/golangci/golangci-lint/pull/1869/files) and configure stderr/stdout explicitly.

@ldez
Copy link
Member

ldez commented Apr 25, 2021

For me, #1869 fixes #1868, what is the value to do it differently? 🤔

@kamilsk
Copy link
Contributor Author

kamilsk commented Apr 25, 2021

After #1869 the only possible way to test it is integration test, because you need to check os.Stdout. The pr fixes that and you can write unit test instead of integration test to check output, just provide buffer as stdout/stderr.

@ldez ldez added blocked Need's direct action from maintainer and removed feedback required Requires additional feedback labels Apr 25, 2021
@kamilsk kamilsk requested review from ernado and jirfag April 26, 2021 08:31
@kamilsk kamilsk marked this pull request as ready for review April 26, 2021 08:31
@ldez ldez removed request for ernado and jirfag April 26, 2021 10:53
@kamilsk kamilsk closed this Apr 26, 2021
@kamilsk kamilsk deleted the improve-code branch April 26, 2021 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Need's direct action from maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants