Skip to content

refactor: replace deprecated io/ioutil with os package equivalents - #115

Open
saiashok0981 wants to merge 1 commit into
kubeslice:masterfrom
saiashok0981:dev/1
Open

refactor: replace deprecated io/ioutil with os package equivalents#115
saiashok0981 wants to merge 1 commit into
kubeslice:masterfrom
saiashok0981:dev/1

Conversation

@saiashok0981

Copy link
Copy Markdown

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

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
@saiashok0981

Copy link
Copy Markdown
Author

please check my pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant