Golang os.SameFile() and os.Stat() functions example

package os

Golang os.SameFile() and os.Stat() functions usage example

 package main

 import (
 "fmt"
 "os"
 )

 func main() {

 inStat, _ := os.Stat("in.txt")
 outStat, _ := os.Stat("out.txt")

 same := os.SameFile(inStat, outStat)

 fmt.Println("The files are same : ", same)
 }

Sample output :

The files are same : false

References :

http://golang.org/pkg/os/#SameFile

http://golang.org/pkg/os/#Stat

Advertisement