Skip to content

Commit

Permalink
remove io/ioutil usage
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux committed Jan 15, 2024
1 parent ce2e741 commit 4ddc36c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions apt/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
// Extracted from https://github.com/arduino/go-apt-client
// Fixes:
// - fix option parsing when no component is provided
// - remove io/ioutil usage

package apt

import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -40,7 +41,6 @@ func parseAPTConfigLine(line string) *Repository {
return nil
}
fields := match[0]
//fmt.Printf("%+v\n", fields)
return &Repository{
Enabled: fields[1] != "# ",
SourceRepo: fields[2] == "deb-src",
Expand All @@ -53,7 +53,7 @@ func parseAPTConfigLine(line string) *Repository {
}

func parseAPTConfigFile(configPath string) (RepositoryList, error) {
data, err := ioutil.ReadFile(configPath)
data, err := os.ReadFile(configPath)
if err != nil {
return nil, fmt.Errorf("Reading %s: %s", configPath, err)
}
Expand All @@ -63,7 +63,6 @@ func parseAPTConfigFile(configPath string) (RepositoryList, error) {
for scanner.Scan() {
line := scanner.Text()
repo := parseAPTConfigLine(line)
//fmt.Printf("%+v\n", repo)
if repo != nil {
repo.configFile = configPath
res = append(res, repo)
Expand All @@ -79,7 +78,7 @@ func parseAPTConfigFolder(folderPath string) (RepositoryList, error) {
sources := []string{filepath.Join(folderPath, "sources.list")}

sourcesFolder := filepath.Join(folderPath, "sources.list.d")
list, err := ioutil.ReadDir(sourcesFolder)
list, err := os.ReadDir(sourcesFolder)
if err != nil {
return nil, fmt.Errorf("Reading %s folder: %s", sourcesFolder, err)
}
Expand Down

0 comments on commit 4ddc36c

Please sign in to comment.