func IsDirectoryEmpty(dir string) (bool, error) {
	f, err := os.Open(dir)
	if err != nil {
		return false, err
	}
	defer f.Close()
	_, err = f.Readdir(1)
	if err == io.EOF {
		return true, nil
	}
	return false, err
}
IsDirectoryEmpty checks if a directory is empty.
package path
import (
	"fmt"
	"io"
	"os"
	"os/user"
	"path/filepath"
	"strings"
)
const DefaultGlideFile = "glide.yaml"
var VendorDir = "vendor"
var Tmp = ""
var homeDir = ""
var GlideFile = DefaultGlideFile
const LockFile = "glide.lock"
func Home() string {
	if homeDir != "" {
		return homeDir
	}
	u, err := user.Current()
	if err == nil && u.HomeDir != "" {
		homeDir = filepath.Join(u.HomeDir, ".glide")
	} else {
		cwd, err := os.Getwd()
		if err == nil {
			homeDir = filepath.Join(cwd, ".glide")
		} else {
			homeDir = ".glide"
		}
	}
	return homeDir
}
func SetHome(h string) {
	homeDir = h
}
func Vendor() (string, error) {
	cwd, err := os.Getwd()
	if err != nil {
		return "", err
	}
	yamldir, err := GlideWD(cwd)
	if err != nil {
		return cwd, err
	}
	gopath := filepath.Join(yamldir, VendorDir)
	info, err := os.Lstat(gopath)
	if err != nil {
		return gopath, nil
	}
	for i := 0; IsLink(info) && i < 255; i++ {
		p, err := os.Readlink(gopath)
		if err != nil {
			return gopath, nil
		}
		if filepath.IsAbs(p) {
			gopath = p
		} else {
			gopath = filepath.Join(filepath.Dir(gopath), p)
		}
		info, err = os.Lstat(gopath)
		if err != nil {
			return gopath, nil
		}
	}
	return gopath, nil
}
func Glide() (string, error) {
	cwd, err := os.Getwd()
	if err != nil {
		return "", err
	}
	yamldir, err := GlideWD(cwd)
	if err != nil {
		return cwd, err
	}
	gf := filepath.Join(yamldir, GlideFile)
	return gf, nil
}
func GlideWD(dir string) (string, error) {
	fullpath := filepath.Join(dir, GlideFile)
	if _, err := os.Stat(fullpath); err == nil {
		return dir, nil
	}
	base := filepath.Dir(dir)
	if base == dir {
		return "", fmt.Errorf("Cannot resolve parent of %s", base)
	}
	return GlideWD(base)
}
func Gopath() string {
	gopaths := Gopaths()
	if len(gopaths) == 0 {
		return ""
	}
	return gopaths[0]
}
func Gopaths() []string {
	p := os.Getenv("GOPATH")
	p = strings.Trim(p, string(filepath.ListSeparator))
	return filepath.SplitList(p)
}
func Basepath() string {
	base, err := os.Getwd()
	if err != nil {
		return "."
	}
	return base
}
func StripBasepath(p string) string {
	bp := Basepath()
	return strings.TrimPrefix(p, bp+string(os.PathSeparator))
}
func IsLink(fi os.FileInfo) bool {
	return fi.Mode()&os.ModeSymlink == os.ModeSymlink
}
func HasLock(basepath string) bool {
	_, err := os.Stat(filepath.Join(basepath, LockFile))
	return err == nil
}