<p>Hi guys!</p>
<p>I'm totally new to go and VS Code, so please excuse me for this (probably) trivial question. I installed golang with brew, installed the analysis tools into GOPATH, and added the go extension to visual studio code. I can build the go file when saving.. thats good.
But, i didn't find i way to run the go code.. Is there a shortcut to compile and run the code or do i have to run it in the console?</p>
<p>Thanks in advance! cheers</p>
<hr/>**评论:**<br/><br/>captncraig: <pre><p>You can customize the tasks.json file in your workspace. I have it set up with a <code>go run *.go</code> command. It is a bit tricky to set up. Here is kinda what I use. </p>
<pre><code>{
"version": "0.1.0",
"command": "bash",
"isShellCommand": true,
"showOutput": "always",
"args": [
"-c"
],
"options": {
"cwd": "${fileDirname}"
},
"tasks": [
{
"taskName": "Go Run",
"suppressTaskName": true,
"isBuildCommand": true,
"args": ["go run *.go"]
},
{
"taskName": "Go Test",
"suppressTaskName": true,
"isTestCommand": true,
"args": ["go test -v"]
}
]
}
</code></pre>
<p>That format kinda sucks. My root command is <code>bash -c</code> and I put the specific args in the subtasks.</p>
<p>With this I can run the keybinding for build and test to do stuff from the current file directory. You can customize the tasks per workspace or add additional custom tasks and such.</p></pre>lambd0r: <pre><p>Ohh!! thanks alot!</p></pre>Malangelus: <pre><p>I've been doing it in the console. If there's a built in way then I'd love to hear about it too</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传