Skip to content

Commit c8888d0

Browse files
committed
Automatically pass the file to run to 'go run'
1 parent 8b22e25 commit c8888d0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

commands/run.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ func Run() error {
3737
if err != nil {
3838
return cli.Error("Not in a CodeGame project directory")
3939
}
40+
wd, _ := os.Getwd()
41+
rootRelative, err := filepath.Rel(wd, root)
42+
if err != nil {
43+
return err
44+
}
4045

4146
data, err := cgfile.LoadCodeGameFile(root)
4247
if err != nil {
@@ -53,7 +58,7 @@ func Run() error {
5358
switch data.Lang {
5459
case "go":
5560
cmdName = "go"
56-
args = append(args, "run")
61+
args = append(args, []string{"run", filepath.Join(rootRelative, "main.go")}...)
5762
default:
5863
return cli.Error("'run' is not supported for '%s'", data.Lang)
5964
}

0 commit comments

Comments
 (0)