![](/style/images/good.png)
9
![](/style/images/bad.png)
[Golang] Compare the Size of Two Files
source link: http://siongui.github.io/2018/04/08/go-compare-size-of-two-files/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[Golang] Compare the Size of Two Files
April 08, 2018
This post shows how to check if the size of two files is the same. Use os.Stat [2] to read information (os.FileInfo) of file and check if the size is the same.
import ( "os" ) func isFileSameSize(path1, path2 string) (sameSize bool, err error) { f1, err := os.Stat(path1) if err != nil { return } f2, err := os.Stat(path2) if err != nil { return } sameSize = (f1.Size() == f2.Size()) return }
Tested on: Ubuntu Linux 17.10, Go 1.10
References:
Author: Siong-Ui Te ∈ Category: Go
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK