{"id":338,"date":"2020-07-22T12:29:10","date_gmt":"2020-07-22T11:29:10","guid":{"rendered":"https:\/\/blog.thomarite.uk\/?p=338"},"modified":"2020-07-22T12:29:10","modified_gmt":"2020-07-22T11:29:10","slug":"vim-golang","status":"publish","type":"post","link":"https:\/\/blog.thomarite.uk\/index.php\/2020\/07\/22\/vim-golang\/","title":{"rendered":"Vim + Golang"},"content":{"rendered":"\n<p>I am trying to learn a bit of <a href=\"https:\/\/golang.org\/\">golang<\/a> (although sometimes I think I should try to master python and bash first..) with this <a href=\"https:\/\/www.udemy.com\/course\/learn-how-to-code\/\">udemy course<\/a>.<\/p>\n\n\n\n<p>The same way I have pyenv\/virtualenv to create python environments, I want to do the same for golang. So for that we have <a href=\"https:\/\/github.com\/syndbg\/goenv\">goenv<\/a>:<\/p>\n\n\n\n<p>Based on goenv install instructions and ex-collegue snipset, this is my goenv snipset in .bashrc:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>########################\n# Go configuration\n########################\n#\n# git clone -b v0.0.4 https:\/\/github.com\/wfarr\/goenv.git $HOME\/.goenv\nif &#91; ! -d \"$HOME\/.goenv\" ]; then\n    git clone https:\/\/github.com\/syndbg\/goenv.git $HOME\/.goenv\nfi\n\nif &#91; -d \"$HOME\/.goenv\"   ]\nthen\n    export GOENV_ROOT=\"$HOME\/.goenv\"\n    export PATH=\"$GOENV_ROOT\/bin:$PATH\"\n    if  type \"goenv\" &amp;> \/dev\/null; then\n        eval \"$(goenv init -)\"\n        # Add the version to my prompt\n        __goversion (){\n            if  type \"goenv\" &amp;> \/dev\/null; then\n                goenv_go_version=$(goenv version | sed -e 's\/ .*\/\/')\n                printf $goenv_go_version\n            fi\n        }\n        #PS1_GO=\"go:\\$(__goversion) \"\n        export PS1=\"go:\\$(__goversion)|$PS1\"\n        export PATH=\"$GOROOT\/bin:$PATH\"\n        export PATH=\"$PATH:$GOPATH\/bin\"\n    fi\nfi\n\n################## End GoLang #####################\n<\/code><\/pre>\n\n\n\n<p><strong>From time to time<\/strong>, remember to go to ~.goenv and do a &#8220;git pull&#8221; to get the latest versions of golang.<\/p>\n\n\n\n<p>Ok, once we can install any golang version, I was thinking about the equivalent to python virtualenv, but it seems <a href=\"https:\/\/eli.thegreenplace.net\/2020\/you-dont-need-virtualenv-in-go\/\">it is not really needed<\/a> in golang. At the moment, I am super beginner so no rush about this.<\/p>\n\n\n\n<p>And finally, as I try to use VIM for everything so I can keep learning, I want to use similar python plugins for golang. So I searched and this one looks quite good: <a href=\"https:\/\/github.com\/fatih\/vim-go\">vim-go<\/a><\/p>\n\n\n\n<p>So I updated  <a href=\"https:\/\/github.com\/VundleVim\/Vundle.vim\">vundle<\/a> config in .vimrc:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Plugin 'fatih\/vim-go', { 'do': ':GoUpdateBinaries' }<\/code><\/pre>\n\n\n\n<p>Then install the new new plugin once in VIM.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">:PluginInstall\n\nor >\n\n:PluginUpdate<\/pre>\n\n\n\n<p>There is a <a href=\"https:\/\/github.com\/fatih\/vim-go\/wiki\/Tutorial\">good tutorial<\/a> you can follow to learn the new commands.<\/p>\n\n\n\n<p>I am happy enough with &#8220;GoRun&#8221;, &#8220;GoFmt&#8221;, &#8220;GoImports&#8221;, &#8220;GoTest&#8221;<\/p>\n\n\n\n<p>Keep practising, Keep learning.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am trying to learn a bit of golang (although sometimes I think I should try to master python and bash first..) with this udemy course. The same way I have pyenv\/virtualenv to create python environments, I want to do the same for golang. So for that we have goenv: Based on goenv install instructions &hellip; <a href=\"https:\/\/blog.thomarite.uk\/index.php\/2020\/07\/22\/vim-golang\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Vim + Golang&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,26],"tags":[],"class_list":["post-338","post","type-post","status-publish","format-standard","hentry","category-golang","category-vim"],"_links":{"self":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/comments?post=338"}],"version-history":[{"count":1,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/338\/revisions"}],"predecessor-version":[{"id":339,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/338\/revisions\/339"}],"wp:attachment":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/media?parent=338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/categories?post=338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/tags?post=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}