Skip to content

Instantly share code, notes, and snippets.

@tcnksm
Last active October 27, 2015 13:29
Show Gist options
  • Save tcnksm/1384868b03df42a3a1b4 to your computer and use it in GitHub Desktop.
Save tcnksm/1384868b03df42a3a1b4 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"os"
"testing"
)
func Test_chdir(t *testing.T) {
fmt.Println(os.Getwd())
dir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal(err)
}
fmt.Println(dir)
if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
fmt.Println(os.Getwd())
}
$ go test -v
=== RUN   Test_chdir
/Users/taichi.nakashima/src/github.com/tcnksm-sample/test-chdir <nil>
/var/folders/hk/t6xpt_j974gfnv_nd3t79x3h2b8vpv/T/544018699
/private/var/folders/hk/t6xpt_j974gfnv_nd3t79x3h2b8vpv/T/544018699 <nil>
--- PASS: Test_chdir (0.00s)
PASS
ok      github.com/tcnksm-sample/test-chdir     0.007s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment