Comparing files (or more generally two finite io.Reader
) is not as easy due to edge-cases like short reads and how errors (including EOF
) are returned by calls to Read
according to the interface specification.
This packages (tries) to deliver a solid implementation for these cases.
go get github.com/hlubek/readercomp
package main
import (
"fmt"
"log"
"os"
"github.com/hlubek/readercomp"
)
func main() {
result, err := readercomp.FilesEqual(os.Args[1], os.Args[2])
if err != nil {
log.Fatal(err)
}
fmt.Println(result)
}
MIT.