Golang: Check File Exist

By Xah Lee. Date: .
package main

import "fmt"
import "os"

// fileExist. check if a file exist
func fileExist(path string) bool {
	_, err := os.Stat(path)
	if err == nil {
		return true
	}
	return false
}

func main() {
	fmt.Printf("%v\n", fileExist("/Users/x/xyz.txt"))
}

golang, read write file