Che: Go sample can't run files without task

Created on 24 Jul 2019  路  7Comments  路  Source: eclipse/che

Is your task related to a problem? Please describe.

Our golang devfile (https://github.com/eclipse/che-devfile-registry/tree/master/devfiles/go) uses https://github.com/golang/example.git as a sample project. It has many runnable files with func main(), but we have only tasks for outyet subproject. AFAIK there is no way how to run Go file from IDE. Some languages can run files with little Run | Debug hovering over the runnable function, bug in Go, this does not work. So only way how to run files is by running terminal and write commands. I would consider this as not good IDE user experience.

Describe the solution you'd like

  • we should consider to use simpler Go sample with only one runnable file.
  • there should be way to run Go file with func main().

Describe alternatives you've considered

  • do nothing, user can run files from terminal
  • add more tasks
areeditoche-theia arelanguages kinbug tealanguages

Most helpful comment

@slemeur @sparkoo
a command for running the current file can look like the following:

        }
            "type": "che",
            "label": "run current file",
            "command": "go get -d && go run ${file}",
            "target": {
                "containerName": "go-cli"
            }
        }

FYI all the variables that can be processed by the substitution mechanism are available through Variable: List All command in Theia commands palette.

Note, resolving the variables in the command property for che tasks will come with the PR https://github.com/eclipse/che-theia/pull/373

All 7 comments

Could the command be parameterized so it take the file name? We used to have that in the commands macro?
cc @RomanNikitenko and @azatsarynnyy

Yes, it can be parameterized.
I think the best solution would be adding Run CodeLens support for func main() into VS Code Go extension upstream project.

@azatsarynnyy that would be awesome. parametrized task is ok for now, I guess

@azatsarynnyy Could you please show how to configure that task to @sparkoo ?

I don't think it's something very costly so we should take it as part of the 7.0 or 7.1
@rhopp : as you are triager today, I rely on you ;)

@slemeur @sparkoo
a command for running the current file can look like the following:

        }
            "type": "che",
            "label": "run current file",
            "command": "go get -d && go run ${file}",
            "target": {
                "containerName": "go-cli"
            }
        }

FYI all the variables that can be processed by the substitution mechanism are available through Variable: List All command in Theia commands palette.

Note, resolving the variables in the command property for che tasks will come with the PR https://github.com/eclipse/che-theia/pull/373

I'm labelling this issue as bug (as misconfiguration of the command).

Was this page helpful?
0 / 5 - 0 ratings