Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: s/TrimRight/TrimSuffix for certain cases #618

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions buddyinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
return nil, fmt.Errorf("%w: Invalid number of fields, found: %v", ErrFileParse, parts)
}

node := strings.TrimRight(parts[1], ",")
zone := strings.TrimRight(parts[3], ",")
node := strings.TrimSuffix(parts[1], ",")
zone := strings.TrimSuffix(parts[3], ",")
arraySize := len(parts[4:])

if bucketCount == -1 {
Expand Down
2 changes: 1 addition & 1 deletion proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (p Proc) CmdLine() ([]string, error) {
return []string{}, nil
}

return strings.Split(string(bytes.TrimRight(data, string("\x00"))), string(byte(0))), nil
return strings.Split(string(bytes.TrimRight(data, "\x00")), "\x00"), nil
}

// Wchan returns the wchan (wait channel) of a process.
Expand Down
2 changes: 1 addition & 1 deletion proc_smaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *ProcSMapsRollup) parseLine(line string) error {
}

v := strings.TrimSpace(kv[1])
v = strings.TrimRight(v, " kB")
v = strings.TrimSuffix(v, " kB")

vKBytes, err := strconv.ParseUint(v, 10, 64)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion sysfs/system_cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func parseCPURange(data []byte) ([]uint16, error) {

var cpusInt = []uint16{}

for _, cpu := range strings.Split(strings.TrimRight(string(data), "\n"), ",") {
for _, cpu := range strings.Split(strings.TrimSuffix(string(data), "\n"), ",") {
if cpu == "" {
continue
}
Expand Down