refactor: replace deprecated io/ioutil with os package equivalents - #115
Open
saiashok0981 wants to merge 1 commit into
Open
refactor: replace deprecated io/ioutil with os package equivalents#115saiashok0981 wants to merge 1 commit into
saiashok0981 wants to merge 1 commit into
Conversation
The io/ioutil package was deprecated in Go 1.16. All functions in that package are simple aliases to equivalent functions in the 'os' and 'io' standard library packages with identical signatures and behaviour. This commit removes the dependency on io/ioutil across three files: - pkg/cmd-util.go: ioutil.ReadFile -> os.ReadFile - pkg/internal/values.go: ioutil.WriteFile -> os.WriteFile - pkg/internal/kubernetes-operation.go: ioutil.ReadFile/WriteFile -> os equivalents Using the canonical os package functions is the idiomatic approach recommended by the Go team for all projects targeting Go 1.16 or later. This project's go.mod declares go 1.17, so the migration is both safe and encouraged. Signed-off-by: saiashok103@gmail.com
Author
|
please check my pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR removes usage of the deprecated io/ioutil package and replaces it with the standard os package equivalents across the codebase.
Motivation
The io/ioutil package was marked deprecated in Go 1.16. All of its functions were moved to the os and io packages with the exact same signatures. Since this project uses Go 1.17, there is no reason to keep using the old deprecated package. Linters like staticcheck will flag this, and it can confuse new contributors. Cleaning this up keeps the codebase modern and aligned with current Go standards.
Changes
In pkg/cmd-util.go, replaced ioutil.ReadFile with os.ReadFile and removed the io/ioutil import.
In pkg/internal/values.go, replaced ioutil.WriteFile with os.WriteFile and removed the io/ioutil import.
In pkg/internal/kubernetes-operation.go, replaced both ioutil.ReadFile and ioutil.WriteFile with the os equivalents and removed the io/ioutil import.
Testing
Verified the changes compile without errors.
The replacement functions have identical signatures so there is no behaviour change.
Existing tests continue to pass.
Checklist
Follows the existing code style of the project
No new dependencies added
No breaking changes
Commit message uses Conventional Commits format
DCO Signed-off-by included
Signed-off-by:
saiashok103@gmail.com