Skip to content

Commit abf307d

Browse files
committed
Fix building and debugging in Windows
1 parent ef755a8 commit abf307d

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

.vscode/tasks.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
"focus": false,
1313
"panel": "shared"
1414
},
15-
"args": ["build", "-o", "gitea", "${workspaceRoot}/main.go"],
15+
"args": ["build"],
16+
"linux": {
17+
"args": [ "-o", "gitea", "${workspaceRoot}/main.go" ]
18+
},
19+
"osx": {
20+
"args": [ "-o", "gitea", "${workspaceRoot}/main.go" ]
21+
},
1622
"windows": {
17-
"args": ["build", "-o", "gitea.exe", "${workspaceRoot}/main.go"]
23+
"args": [ "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
1824
},
1925
"problemMatcher": ["$go"]
2026
},
@@ -29,9 +35,15 @@
2935
"focus": false,
3036
"panel": "shared"
3137
},
32-
"args": ["build", "-tags=\"sqlite\"", "-o", "gitea", "${workspaceRoot}/main.go"],
38+
"args": ["build", "-tags=\"sqlite\""],
39+
"linux": {
40+
"args": ["-o", "gitea", "${workspaceRoot}/main.go"]
41+
},
42+
"osx": {
43+
"args": ["-o", "gitea", "${workspaceRoot}/main.go"]
44+
},
3345
"windows": {
34-
"args": ["build", "-tags=\"sqlite\"", "-o", "gitea.exe", "${workspaceRoot}/main.go"]
46+
"args": ["-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""]
3547
},
3648
"problemMatcher": ["$go"]
3749
}

modules/setting/setting.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,11 @@ func DateLang(lang string) string {
500500

501501
// execPath returns the executable path.
502502
func execPath() (string, error) {
503-
file, err := exec.LookPath(os.Args[0])
503+
execFile := os.Args[0]
504+
if IsWindows && filepath.IsAbs(execFile) {
505+
return filepath.Clean(execFile), nil
506+
}
507+
file, err := exec.LookPath(execFile)
504508
if err != nil {
505509
return "", err
506510
}

0 commit comments

Comments
 (0)