Skip to content

Commit 1719c31

Browse files
committed
feat: add checking os type
1 parent b8db6b3 commit 1719c31

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/checkOS.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package app
2+
3+
import (
4+
"log"
5+
"os"
6+
"runtime"
7+
)
8+
9+
func checkOStype() {
10+
if runtime.GOOS == "linux" {
11+
os.Setenv("QT_QPA_PLATFORM", "xcb") // Sets x11 for linux
12+
log.Println("Running on Linux")
13+
} else if runtime.GOOS == "windows" {
14+
log.Println("Running on Windows")
15+
} else if runtime.GOOS == "darwin" {
16+
log.Println("Running on MacOS")
17+
} else {
18+
log.Println("System type cannot be detected")
19+
}
20+
}

src/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ func (w *MainWindow) exit(_ bool) {
490490

491491
func Main() {
492492

493+
checkOStype()
494+
493495
app := widgets.NewQApplication(len([]string{}), []string{})
494496

495497
if core.QCoreApplication_Instance() == nil {

0 commit comments

Comments
 (0)