title: How to change the current directory in Go
body: <p>Unlike <em><a href="https://stackoverflow.com/questions/44206940/golang-execute-cd-command-for-cmd">Execute the &#39;cd&#39; command for CMD in Go</a></em>, I just want to really run <code>cd directory_location</code> using Go and change the current directory.</p>
  <p>So for example,</p>
  <p>Say I am on ~/goproject, and I run, <code>./main</code> in the terminal, I want to be at ~/goproject2 in the terminal.</p>
  <p>I tried</p>
  <pre><code>cmd := exec.Command(&quot;bash&quot;, &quot;-c&quot;, &quot;cd&quot;, &quot;~/goproject2&quot;)
  cmd.Run()
  </code></pre>
  <p>But this didn't actually change the current directory.</p>