On unix they use the access syscall which is faster than stat for
simply checking the existence of a file.
with a file in the cache I see on my machine:
$ go test -bench=.
goos: linux
goarch: amd64
pkg: github.com/containers/storage/pkg/fileutils
cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
BenchmarkExists-12 925832 1245 ns/op
BenchmarkStat-12 745896 1602 ns/op
PASS
I'd expect even better results if the file is not already in the cache.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>