<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yusuke Hatanaka</title>
    <description>The latest articles on DEV Community by Yusuke Hatanaka (@hatajoe).</description>
    <link>https://dev.to/hatajoe</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F43087%2F72657362-8ec5-4ece-8b5b-f37628594ab2.jpg</url>
      <title>DEV Community: Yusuke Hatanaka</title>
      <link>https://dev.to/hatajoe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hatajoe"/>
    <language>en</language>
    <item>
      <title>Getting started to writing an App by Go</title>
      <dc:creator>Yusuke Hatanaka</dc:creator>
      <pubDate>Thu, 16 Nov 2017 15:02:41 +0000</pubDate>
      <link>https://dev.to/hatajoe/getting-started-to-writing-an-app-by-go-dg2</link>
      <guid>https://dev.to/hatajoe/getting-started-to-writing-an-app-by-go-dg2</guid>
      <description>&lt;p&gt;We have things to care about when before writing the Go code.That is about management of GOPATH and vendor package versioning.&lt;/p&gt;

&lt;p&gt;GOPATH is having a large package dependency scope by default.This cause a performance degradation of a build, editor, and other relational tools.Furthermore, it is difficult to manage package versions. &lt;em&gt;go get&lt;/em&gt; fetch packages to the same context of each package.&lt;/p&gt;

&lt;p&gt;But we can solve this by changing GOPATH depending on that context.There are a little bit different method of the standalone apps and reusable packages.&lt;/p&gt;

&lt;p&gt;I introduce how to get started.&lt;/p&gt;

&lt;h1&gt;
  
  
  Install direnv
&lt;/h1&gt;

&lt;p&gt;Before reading this, there is an article I wrote before, I recommend you read that first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/hatajoe/preparing-the-development-environment-for-go-in-late-2017-a73"&gt;Preparing the development environment for Go in late 2017&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;direnv&lt;/em&gt; is a tool that an environment switcher for the shell.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/direnv/direnv"&gt;direnv/direnv&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, you can use arbitrary directories as GOPATH.You can get a minimum scoped development environment in this way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;% echo $GOPATH
/Users/hatajoe
% cd work
% mkdir app
% cd app
% direnv edit .
use go go1.9.2
layout go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By doing this, GOPATH is changed to &lt;em&gt;/Users/hatajoe/work/app&lt;/em&gt; when moving into &lt;em&gt;/app&lt;/em&gt; directory.&lt;/p&gt;

&lt;h1&gt;
  
  
  Install dep
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;dep&lt;/em&gt; is a tool that for Go dependency management.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/golang/dep"&gt;golang/dep&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By using &lt;em&gt;dep&lt;/em&gt;, we can fetch the same revision packages at any time.&lt;/p&gt;

&lt;h1&gt;
  
  
  standalone apps
&lt;/h1&gt;

&lt;p&gt;The definition of standalone is whether it is referenced by others or not.If you make a standalone app, doing like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;% pwd
/Users/hatajoe/work
% mkdir app
% cd app
% direnv edit .
use go go1.9.2
layout go
% git init
% git add .
% git commit -m “initial commit”
% mkdir -p src/app
% cd src/app
% dep init
% ls
Gopkg.lock Gopkg.toml vendor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it! We ready to start coding.&lt;/p&gt;

&lt;h1&gt;
  
  
  reusable packages
&lt;/h1&gt;

&lt;p&gt;If you make a reusable package, doing like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;% pwd
/Users/hatajoe/work
% mkdir my-package
% cd my-package
% direnv edit .
use go go1.9.2
layout go
% mkdir src/github.com/hatajoe/my-package
% cd src/github.com/hatajoe/my-package
% dep init
% ls
Gopkg.lock Gopkg.toml vendor
% git init
% git add .
% git commit -m “initial commit”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You know that it has a little bit different from standalone apps.&lt;/p&gt;




&lt;p&gt;Thank you for reading. Feedback is welcome.&lt;br&gt;
If you have any ideas and improvements feel free to respond me!&lt;/p&gt;

</description>
      <category>dep</category>
      <category>go</category>
      <category>programming</category>
      <category>direnv</category>
    </item>
    <item>
      <title>Preparing the development environment for Go in late 2017</title>
      <dc:creator>Yusuke Hatanaka</dc:creator>
      <pubDate>Sat, 04 Nov 2017 06:35:31 +0000</pubDate>
      <link>https://dev.to/hatajoe/preparing-the-development-environment-for-go-in-late-2017-a73</link>
      <guid>https://dev.to/hatajoe/preparing-the-development-environment-for-go-in-late-2017-a73</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;gvm&lt;/li&gt;
&lt;li&gt;direnv&lt;/li&gt;
&lt;li&gt;Go&lt;/li&gt;
&lt;li&gt;GoLand&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  gvm
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/moovweb/gvm"&gt;moovweb/gvm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;gvm is most popular Go Version Manager as far as I know.&lt;br&gt;
It’s able to switch version of Go in easily.&lt;/p&gt;

&lt;p&gt;Install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;% bash &amp;lt; &amp;lt;(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
% vi ~/.zshenv
[[-s ~/.gvm/scripts/gvm]] &amp;amp;&amp;amp; . ~/.gvm/scripts/gvm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  direnv
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/direnv/direnv"&gt;direnv/direnv&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;direnv has good compatibility with Go, that can switch GOPATH without care.&lt;/p&gt;

&lt;p&gt;Install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;% brew install direnv
% vi ~/.zshenv
[[-f /usr/local/bin/direnv]] &amp;amp;&amp;amp; \
  eval “$(direnv hook zsh)”
% vi ~/.direnvrc
use_go(){
 . $GVM_ROOT/scripts/gvm-default
 gvm use $1
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Go1.9.2
&lt;/h2&gt;

&lt;p&gt;Installing latest Go as binary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;% gvm install go1.9.2 -B
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  GoLand
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.jetbrains.com/go/"&gt;GoLand: Capable and Ergonomic Go IDE by JetBrains&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GoLand is IDE developed by JetBrains.&lt;br&gt;
It’ll be able to use without tedious settings. (I like also vim-go, but I use this recently, It’s easy)&lt;/p&gt;

&lt;h1&gt;
  
  
  Getting Started
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;% mkdir awesome-project
% cd awesome-project
% direnv edit
use go go1.9.2
layout go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ready to be done!&lt;/p&gt;

</description>
      <category>goland</category>
      <category>gvm</category>
      <category>direnv</category>
      <category>go</category>
    </item>
  </channel>
</rss>
