os.Chdir(“ / tmp”)在Go中工作异常

I used Macbook. I tried to use os.Chdir("/tmp") but the outcome was /private/tmp. Following is my code:

package main

import (
  "fmt"
  "os"
)

func main() {
  s, _ := os.Getwd()
  fmt.Println(s)

  if err := os.Chdir("/tmp"); err != nil {
    panic(err)
  }
  s, _ = os.Getwd()
  fmt.Println(s)

}

And the output is:

➜  test   go run main.go
/Users/willy/test
/private/tmp

Why?

As chown in this Apple thread

On OS X, /tmp is an alias for /private/tmp.

$ ls -ale / | grep -i tmp

lrwxr-xr-x@    1 root  wheel        11 Aug 30  2009 tmp -> private/tmp

$

And a golang syscall.Chdir() would follow that symlink.
So the final path is expected on a Mac OS platform.