@@ -18,7 +18,7 @@ package procfs
1818import (
1919 "bufio"
2020 "bytes"
21- "errors "
21+ "fmt "
2222 "regexp"
2323 "strconv"
2424 "strings"
@@ -77,7 +77,7 @@ func parseCPUInfoX86(info []byte) ([]CPUInfo, error) {
7777 // find the first "processor" line
7878 firstLine := firstNonEmptyLine (scanner )
7979 if ! strings .HasPrefix (firstLine , "processor" ) || ! strings .Contains (firstLine , ":" ) {
80- return nil , errors . New ("invalid cpuinfo file: " + firstLine )
80+ return nil , fmt . Errorf ("invalid cpuinfo file: %q" , firstLine )
8181 }
8282 field := strings .SplitN (firstLine , ": " , 2 )
8383 v , err := strconv .ParseUint (field [1 ], 0 , 32 )
@@ -192,7 +192,7 @@ func parseCPUInfoARM(info []byte) ([]CPUInfo, error) {
192192 firstLine := firstNonEmptyLine (scanner )
193193 match , _ := regexp .MatchString ("^[Pp]rocessor" , firstLine )
194194 if ! match || ! strings .Contains (firstLine , ":" ) {
195- return nil , errors . New ("invalid cpuinfo file: " + firstLine )
195+ return nil , fmt . Errorf ("invalid cpuinfo file: %q" , firstLine )
196196 }
197197 field := strings .SplitN (firstLine , ": " , 2 )
198198 cpuinfo := []CPUInfo {}
@@ -256,7 +256,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) {
256256
257257 firstLine := firstNonEmptyLine (scanner )
258258 if ! strings .HasPrefix (firstLine , "vendor_id" ) || ! strings .Contains (firstLine , ":" ) {
259- return nil , errors . New ("invalid cpuinfo file: " + firstLine )
259+ return nil , fmt . Errorf ("invalid cpuinfo file: %q" , firstLine )
260260 }
261261 field := strings .SplitN (firstLine , ": " , 2 )
262262 cpuinfo := []CPUInfo {}
@@ -281,7 +281,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) {
281281 if strings .HasPrefix (line , "processor" ) {
282282 match := cpuinfoS390XProcessorRegexp .FindStringSubmatch (line )
283283 if len (match ) < 2 {
284- return nil , errors . New ( "Invalid line found in cpuinfo: " + line )
284+ return nil , fmt . Errorf ( "invalid cpuinfo file: %q" , firstLine )
285285 }
286286 cpu := commonCPUInfo
287287 v , err := strconv .ParseUint (match [1 ], 0 , 32 )
@@ -341,7 +341,7 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) {
341341 // find the first "processor" line
342342 firstLine := firstNonEmptyLine (scanner )
343343 if ! strings .HasPrefix (firstLine , "system type" ) || ! strings .Contains (firstLine , ":" ) {
344- return nil , errors . New ("invalid cpuinfo file: " + firstLine )
344+ return nil , fmt . Errorf ("invalid cpuinfo file: %q" , firstLine )
345345 }
346346 field := strings .SplitN (firstLine , ": " , 2 )
347347 cpuinfo := []CPUInfo {}
@@ -383,7 +383,7 @@ func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
383383
384384 firstLine := firstNonEmptyLine (scanner )
385385 if ! strings .HasPrefix (firstLine , "processor" ) || ! strings .Contains (firstLine , ":" ) {
386- return nil , errors . New ("invalid cpuinfo file: " + firstLine )
386+ return nil , fmt . Errorf ("invalid cpuinfo file: %q" , firstLine )
387387 }
388388 field := strings .SplitN (firstLine , ": " , 2 )
389389 v , err := strconv .ParseUint (field [1 ], 0 , 32 )
@@ -428,7 +428,7 @@ func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) {
428428
429429 firstLine := firstNonEmptyLine (scanner )
430430 if ! strings .HasPrefix (firstLine , "processor" ) || ! strings .Contains (firstLine , ":" ) {
431- return nil , errors . New ("invalid cpuinfo file: " + firstLine )
431+ return nil , fmt . Errorf ("invalid cpuinfo file: %q" , firstLine )
432432 }
433433 field := strings .SplitN (firstLine , ": " , 2 )
434434 v , err := strconv .ParseUint (field [1 ], 0 , 32 )
@@ -464,7 +464,7 @@ func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) {
464464}
465465
466466func parseCPUInfoDummy (_ []byte ) ([]CPUInfo , error ) { // nolint:unused,deadcode
467- return nil , errors . New ("not implemented" )
467+ return nil , fmt . Errorf ("not implemented" )
468468}
469469
470470// firstNonEmptyLine advances the scanner to the first non-empty line
0 commit comments