在新目录中打开Shell

I am trying to make my shell cd into a directory. Is there a better way to do this? The only problem with this way is that my shell is a subprocess of the current shell. Making me have to exit twice.

package main

func main(){
  err = syscall.Chdir(os.Getenv("HOME") + "/dev")
  exitIfErr(err)
  err = syscall.Exec(os.Getenv("SHELL"), []string{""}, os.Environ())
  exitIfErr(err)
}

You could use os.Chdir instead to change directories:

func Chdir(dir string) error

Chdir changes the current working directory to the named directory. If there is an error, it will be of type *PathError.

Regarding the exec I'd recommend using the os/exec package to run your sub-process. It sorts out all kind of portability nuances between *nix systems and even windows as far as applicable.