Skip to content

Instantly share code, notes, and snippets.

@calavera
Created June 9, 2015 22:59
Show Gist options
  • Save calavera/6953dbaecb887e55298b to your computer and use it in GitHub Desktop.
Save calavera/6953dbaecb887e55298b to your computer and use it in GitHub Desktop.
links.go
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
func main() {
tmp, _ := ioutil.TempDir("", "test-")
os.Mkdir(tmp+"foo", 0755)
l, err := os.Readlink(tmp + "foo")
fmt.Println(err)
fmt.Println(l)
l, err = filepath.EvalSymlinks(tmp + "foo")
fmt.Println(err)
fmt.Println(l)
}
calavera@d /tmp $ go run links.go
readlink /var/folders/js/2dvhvjgs3h90tyjb3t7c23cw0000gn/T/test-698304347foo: invalid argument
<nil>
/private/var/folders/js/2dvhvjgs3h90tyjb3t7c23cw0000gn/T/test-698304347foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment