-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
removes ioutil usage everywhere which was deprecated in go1.16 #15297
Conversation
@dhiaayachi I'm not sure if this one's been proposed before, but thought I'd see if there was any interest in this PR. Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this @kschoche!
Seems like your experiment is working 🚀
I added a comment about a commented code that I think we should remove.
I also have a suggestion to avoid regression for this (as long as ioutils is existing in golang). Maybe we can use something like this https://github.com/le0tk0k/noioutil to vet the code in the CI but feel free to merge this as is and have this in a subsequent PR.
You might be able to use the |
Ahh this is a great find, thanks!
|
.changelog/15297.txt
Outdated
@@ -0,0 +1,3 @@ | |||
```release-note:improvement | |||
all: Remove the use of the deprecated ioutil package throughout the codebase in favour of io and os packages which are still maintained and also introduce a lint rule which forbids the use of ioutil in commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many times this sort of fixup doesn't necessitate a changelog entry. Your call if you think we should have one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! I was on the fence about it, so I'll remove it then, I think the commit message should be good enough!
@@ -1047,7 +1046,7 @@ func (a *ACL) RulesTranslate(rules io.Reader) (string, error) { | |||
parseQueryMeta(resp, qm) | |||
qm.RequestTime = rtt | |||
|
|||
ruleBytes, err := ioutil.ReadAll(resp.Body) | |||
ruleBytes, err := io.ReadAll(resp.Body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we handle go version compatibility differently in the api
package so that folks using the library aren't forced to upgrade to a future version before they're ready. I think the policy seems to be assuming folks are using a go version that is still receiving security updates (which 1.16 is definitely NOT anymore).
So in this case it's fine to do the swap. I wonder if we should correlate this with bumping the go
directive in api/go.mod
from 1.12
to at least 1.16
or maybe all the way to 1.18
(which is the oldest version we test against in CI).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same logic would apply to sdk/go.mod
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏽 Can do, I think 1.18
makes sense here then.
There is a ton of module tidying, save that for another PR?
* update go version to 1.18 for api and sdk, go mod tidy * removes ioutil usage everywhere which was deprecated in go1.16 in favour of io and os packages. Also introduces a lint rule which forbids use of ioutil going forward. Co-authored-by: R.B. Boyer <[email protected]>
…#17243) * no-op commit due to failed cherry-picking * security: update go version to 1.20.4 (#17240) * update go version to 1.20.3 * add changelog * rename changelog file to remove underscore * update to use 1.20.4 * update change log entry to reflect 1.20.4 * upgrading to 1.20 * [OSS] security: update go to 1.20.1 (#16263) * security: update go to 1.20.1 * fixing auto_config_endpoint_test that was merged incorrectly * go mod tidy * fixing auto_config_endpoint_test that was merged incorrectly * updating linter to 1.51.1 * go mod tidy on api * go mod tidy * removes ioutil usage everywhere which was deprecated in go1.16 (#15297) * update go version to 1.18 for api and sdk, go mod tidy * removes ioutil usage everywhere which was deprecated in go1.16 in favour of io and os packages. Also introduces a lint rule which forbids use of ioutil going forward. Co-authored-by: R.B. Boyer <[email protected]> * go mod tidy * getting rd of net in imports * get rid of use of math.rand * get rid of use of math/rand in audo_config_endpoint_test.go * update leader test --------- Co-authored-by: temp <[email protected]> Co-authored-by: John Murret <[email protected]> Co-authored-by: Dan Stough <[email protected]> Co-authored-by: Kyle Schochenmaier <[email protected]>
Description
This is a cleanup PR that I'm testing, it would be sweet if it passed all the unit tests :-D
This PR also introduces a new rules to the
golangci-lint
tool which forbids the use of theioutil
package and will result in output like this:PR Checklist