Visual Studio Code + Golang

polaris · · 1160 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi guys!</p> <p>I&#39;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&#39;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>{ &#34;version&#34;: &#34;0.1.0&#34;, &#34;command&#34;: &#34;bash&#34;, &#34;isShellCommand&#34;: true, &#34;showOutput&#34;: &#34;always&#34;, &#34;args&#34;: [ &#34;-c&#34; ], &#34;options&#34;: { &#34;cwd&#34;: &#34;${fileDirname}&#34; }, &#34;tasks&#34;: [ { &#34;taskName&#34;: &#34;Go Run&#34;, &#34;suppressTaskName&#34;: true, &#34;isBuildCommand&#34;: true, &#34;args&#34;: [&#34;go run *.go&#34;] }, { &#34;taskName&#34;: &#34;Go Test&#34;, &#34;suppressTaskName&#34;: true, &#34;isTestCommand&#34;: true, &#34;args&#34;: [&#34;go test -v&#34;] } ] } </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&#39;ve been doing it in the console. If there&#39;s a built in way then I&#39;d love to hear about it too</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1160 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传