replace deprecated io/ioutil with os and io for cmd

This commit is contained in:
ahrtr
2021-11-02 08:54:28 +08:00
parent 6dd234d85c
commit 972dc46a1f
73 changed files with 187 additions and 239 deletions

View File

@@ -17,7 +17,7 @@ limitations under the License.
package main
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -38,14 +38,14 @@ func MarkdownPostProcessing(cmd *cobra.Command, dir string, processor func(strin
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md"
filename := filepath.Join(dir, basename)
markdownBytes, err := ioutil.ReadFile(filename)
markdownBytes, err := os.ReadFile(filename)
if err != nil {
return err
}
processedMarkDown := processor(string(markdownBytes))
return ioutil.WriteFile(filename, []byte(processedMarkDown), 0644)
return os.WriteFile(filename, []byte(processedMarkDown), 0644)
}
// cleanupForInclude parts of markdown that will make difficult to use it as include in the website: