Skip to content

Commit 08d4a02

Browse files
committed
feat: use filepath join instead of string concatnation
1 parent a4db7c1 commit 08d4a02

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

vmdetect/linux.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io/ioutil"
99
"os"
1010
"os/user"
11+
"path/filepath"
1112
"time"
1213
)
1314

@@ -45,7 +46,7 @@ func checkDMITable() bool {
4546
continue
4647
}
4748

48-
dmiContent, err := ioutil.ReadFile(dmiPath + dmiEntry.Name())
49+
dmiContent, err := ioutil.ReadFile(filepath.Join(dmiPath, dmiEntry.Name()))
4950

5051
if err != nil {
5152
PrintError(err)
@@ -128,11 +129,11 @@ Some virtualization technologies can be detected using /proc/device-tree
128129
func checkDeviceTree() bool {
129130
deviceTreeBase := "/proc/device-tree"
130131

131-
if DoesFileExist(deviceTreeBase + "/hypervisor/compatible") {
132+
if DoesFileExist(filepath.Join(deviceTreeBase, "/hypervisor/compatible")) {
132133
return true
133134
}
134135

135-
if DoesFileExist(deviceTreeBase + "/fw-cfg") {
136+
if DoesFileExist(filepath.Join(deviceTreeBase, "/fw-cfg")) {
136137
return true
137138
}
138139

0 commit comments

Comments
 (0)