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

Replace deprecated io/ioutil with io and os packages #7212

Merged
merged 2 commits into from
Sep 23, 2022
Merged

Replace deprecated io/ioutil with io and os packages #7212

merged 2 commits into from
Sep 23, 2022

Conversation

Juneezee
Copy link
Contributor

What this PR does / why we need it:

The io/ioutil package has been deprecated in Go 1.16 (See https://pkg.go.dev/io/ioutil). This PR replaces the existing io/ioutil functions with their new definitions in io and os packages.

  • ioutil.Discard => io.Discard
  • ioutil.NopCloser => io.NopCloser
  • ioutil.ReadAll => io.ReadAll
  • ioutil.ReadDir => os.ReadDir (returns a slice of os.DirEntry rather than a slice of fs.FileInfo, this may improve performance in some cases as os.ReadDir is more efficient [1])
  • ioutil.ReadFile => os.ReadFile
  • ioutil.TempDir => os.MkdirTemp
  • ioutil.TempFile => os.CreateTemp
  • ioutil.WriteFile => os.WriteFile

Which issue(s) this PR fixes:

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

[1]: https://golang.org/doc/go1.16#ioutil
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@Juneezee Juneezee requested a review from a team as a code owner September 21, 2022 14:10
@Juneezee Juneezee changed the title Refactor/deprecate ioutil Replace deprecated io/ioutil with io and os packages Sep 21, 2022
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
- querier/queryrange	-0.1%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Copy link
Contributor

@MichelHollands MichelHollands left a comment

Choose a reason for hiding this comment

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

LGTM

@MichelHollands MichelHollands merged commit e2842c6 into grafana:main Sep 23, 2022
lxwzy pushed a commit to lxwzy/loki that referenced this pull request Nov 7, 2022
)

The `io/ioutil` package has been deprecated in Go 1.16 (See
https://pkg.go.dev/io/ioutil). This PR replaces the existing `io/ioutil`
functions with their new definitions in `io` and `os` packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants