ioutil.WriteFile is deprecated, use os.WriteFile instead
481 src := plug.GetInfo().ModulePath + " " + plug.GetInfo().OldVersion
482 dist := plug.GetInfo().ModulePath + " " + plug.GetInfo().Version
483 content = bytes.ReplaceAll(content, []byte(src), []byte(dist))
484 _ = ioutil.WriteFile(h.config.BootstrapFilePath, content, 0644)485 }
486
487 // TODO: 实现运行环境与编译环境隔离
ioutil.WriteFile is deprecated, use os.WriteFile instead
467 if err != nil {
468 logger.Error("read bootstrap file error: ", err)
469 } else {
470 err = ioutil.WriteFile(h.config.BootstrapFilePath, []byte(string(content)+`471import _ "`+plug.GetInfo().ModulePath+`"`), 0644)
472 if err != nil {
473 logger.Error("write bootstrap file error: ", err)
ioutil.ReadFile is deprecated, use os.ReadFile instead
477
478 if h.config.GoModFilePath != "" && utils.FileExist(h.config.GoModFilePath) &&
479 plug.GetInfo().CanUpdate && plug.GetInfo().OldVersion != "" {
480 content, _ := ioutil.ReadFile(h.config.BootstrapFilePath)481 src := plug.GetInfo().ModulePath + " " + plug.GetInfo().OldVersion
482 dist := plug.GetInfo().ModulePath + " " + plug.GetInfo().Version
483 content = bytes.ReplaceAll(content, []byte(src), []byte(dist))
ioutil.ReadFile is deprecated, use os.ReadFile instead
463 }
464
465 if h.config.BootstrapFilePath != "" && utils.FileExist(h.config.BootstrapFilePath) {
466 content, err := ioutil.ReadFile(h.config.BootstrapFilePath)467 if err != nil {
468 logger.Error("read bootstrap file error: ", err)
469 } else {
Description
io/ioutil
package, like most things with util in the name, has turned out to
be a poorly defined and complex to understand the collection of things.
In a series of a few changes, the entire ioutil package will become deprecated starting from Go 1.16.
Existing code using ioutil will continue to work; ioutil will consist of simple wrappers to new functions which reside in the io and os packages.
Bad practice
ioutil.ReadAll(r)
ioutil.ReadFile(filename)
ioutil.ReadDir(dirname)
// ...
Recommended
io.ReadAll(r)
os.ReadFile(filename)
os.ReadDir(dirname)
// ...