removes ioutil usage everywhere which was deprecated in go1.16#15297
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? |
dhiaayachi
left a comment
There was a problem hiding this comment.
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.
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.
Makes sense! I was on the fence about it, so I'll remove it then, I think the commit message should be good enough!
| qm.RequestTime = rtt | ||
|
|
||
| ruleBytes, err := ioutil.ReadAll(resp.Body) | ||
| ruleBytes, err := io.ReadAll(resp.Body) |
There was a problem hiding this comment.
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.
The same logic would apply to sdk/go.mod too.
There was a problem hiding this comment.
👍🏽 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 <4903+rboyer@users.noreply.github.com>
…#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 <4903+rboyer@users.noreply.github.com> * 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 <temp@hashicorp.com> Co-authored-by: John Murret <john.murret@hashicorp.com> Co-authored-by: Dan Stough <dan.stough@hashicorp.com> Co-authored-by: Kyle Schochenmaier <kschoche@gmail.com>
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-linttool which forbids the use of theioutilpackage and will result in output like this:PR Checklist