os: Stat().Size contains incorrect value #23493
Labels
FrozenDueToAge
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
I did compare the contents of FileInfo.Size returned by several stat functions. The resutle of the tests varies depending on the utilized methodes.
testcase 1
fi, err = os.Stat(fqfn)
fi.Size contains a value, that does not match the file size.
testcase 2
fi, err = os.Lstat(fqfn)
fi.Size contains a value, that does not match the file size.
testcase 3
file, err := os.Open( fqfn )
fi, err = file.Stat(fqfn)
fi.Size contains a value, that is correct!
What version of Go are you using (
go version
)?1.9.2
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?windows, amd64
Linux, amd64
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
The value of the Size property should be the same regardless the utilized method. In all tree cases a FileInfo object is returned, that should describe the referenced file correctly.
In my test scenario I did create a text file containing one single byte. All three test cases should return '1' as size.
What did you see instead?
When calling the stat methods I get the following results for a 1 byte file:
2018-01-20 17:09:56, FILE "Neues Textdokument.txt"
Size: 4953040, Neues Textdokument.txt <<-- os.Stat & os.Lstat
Size: 1 <<-- file.Stat
2018-01-20 17:09:57, FILE "Neues Textdokument.txt"
Size: 4953040, Neues Textdokument.txt <<-- os.Stat & os.Lstat
Size: 1 <<-- file.Stat
The text was updated successfully, but these errors were encountered: