Skip to content

Commit de74ae5

Browse files
authored
Merge pull request #401 from Gofastasf/update-code
Improve string and file extension handling: ReplaceAll & filepath.Ext
2 parents e75a40d + ee5c5c4 commit de74ae5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pkg/gpu/gpu_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (i *Info) load() error {
5656
// Building dynamic WHERE clause with addresses to create a single query collecting all desired data
5757
queryAddresses := []string{}
5858
for _, description := range win32VideoControllerDescriptions {
59-
var queryAddres = strings.Replace(description.PNPDeviceID, "\\", `\\`, -1)
59+
var queryAddres = strings.ReplaceAll(description.PNPDeviceID, "\\", `\\`)
6060
queryAddresses = append(queryAddresses, "PNPDeviceID='"+queryAddres+"'")
6161
}
6262
whereClause := strings.Join(queryAddresses[:], " OR ")
@@ -85,7 +85,7 @@ func (i *Info) load() error {
8585

8686
func GetDevice(id string, entities []win32PnPEntity) *pci.Device {
8787
// Backslashing PnP address ID as requested by JSON and VMI query: https://docs.microsoft.com/en-us/windows/win32/wmisdk/where-clause
88-
var queryAddress = strings.Replace(id, "\\", `\\`, -1)
88+
var queryAddress = strings.ReplaceAll(id, "\\", `\\`)
8989
// Preparing default structure
9090
var device = &pci.Device{
9191
Address: queryAddress,

pkg/memory/memory_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func memTotalPhysicalBytesFromSyslog(paths *linuxpath.Paths) int64 {
242242
for _, file := range logFiles {
243243
if strings.HasPrefix(file.Name(), "syslog") {
244244
fullPath := filepath.Join(logDir, file.Name())
245-
unzip := strings.HasSuffix(file.Name(), ".gz")
245+
unzip := filepath.Ext(file.Name()) == ".gz"
246246
var r io.ReadCloser
247247
r, err = os.Open(fullPath)
248248
if err != nil {

0 commit comments

Comments
 (0)