This is a creation in Article, where the information may have evolved or changed.
funcCompare (spath, Dpathstring)BOOL{sinfo, err: = OS. Lstat (spath)ifErr! =Nil{return false} dinfo, err: = OS. Lstat (Dpath)ifErr! =Nil{return false}ifSinfo. Size ()! = Dinfo. Size () | | !sinfo. Modtime (). Equal (Dinfo. Modtime ()) {return false}returnComparefile (spath, Dpath)}funcComparefile (spath, Dpathstring)BOOL{sFile, err: = OS. Open (spath)ifErr! =Nil{return false} dfile, err: = OS. Open (Dpath)ifErr! =Nil{return false} B: = Comparebyte (SFile, Dfile) sfile.close () Dfile.close ()returnb//below can be substituted for MD5 comparison.funcComparebyte (Sfile *os. File, Dfile *os. File)BOOL{varSByte []byte= Make([]byte, +)varDbyte []byte= Make([]byte, +)varSerr, derr Error for{_, Serr = Sfile. Read (SByte) _, Derr = Dfile. Read (Dbyte)ifSerr! =Nil|| Derr! =Nil{ifSerr! = Derr {return false}ifSerr = = Io. EOF { Break} }ifbytes. Equal (sbyte, Dbyte) {Continue}return false}return true}