Examples in Go
package main

import (
	"fmt"
	"os"
)

func main() {

	file, e := os.Stat("/some/path")
	if e != nil {
		panic(e)
	}

	mode := file.Mode()
	if mode.IsDir() {
		fmt.Println("directory")
	} else if mode.IsRegular() {
		fmt.Println("file")
	}
}