Skip to content

Commit

Permalink
Use file reader directly for net stats
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Oct 28, 2015
1 parent c72e0c2 commit 561cc1d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions container/libcontainer/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"bufio"
"fmt"
"io/ioutil"
"os"
"path"
"regexp"
"strconv"
Expand Down Expand Up @@ -155,15 +156,13 @@ func scanInterfaceStats(netStatsFile string) ([]info.InterfaceStats, error) {

stats := []info.InterfaceStats{}

data, err := ioutil.ReadFile(netStatsFile)
file, err := os.Open(netStatsFile)
if err != nil {
return stats, fmt.Errorf("failure opening %s: %v", netStatsFile, err)
}
defer file.Close()

reader := strings.NewReader(string(data))
scanner := bufio.NewScanner(reader)

scanner.Split(bufio.ScanLines)
scanner := bufio.NewScanner(file)

for scanner.Scan() {
line := scanner.Text()
Expand Down

0 comments on commit 561cc1d

Please sign in to comment.