Unlike Execute the 'cd' command for CMD in Go, I just want to really run cd directory_location
using Go and change the current directory.
So for example,
Say I am on ~/goproject, and I run, ./main
in the terminal, I want to be at ~/goproject2 in the terminal.
I tried
cmd := exec.Command("bash", "-c", "cd", "~/goproject2")
cmd.Run()
But this didn't actually change the current directory.
cd
is a shell's built-in command, and you cannot implement it as an external command.