Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #22991

Closed
MohammedAssafly opened this issue Dec 4, 2017 · 1 comment
Closed

Bug #22991

MohammedAssafly opened this issue Dec 4, 2017 · 1 comment

Comments

@MohammedAssafly
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.9.2

Does this issue reproduce with the latest release?

I don't know.

What operating system and processor architecture are you using (go env)?

windows/amd64,

What did you do?

I was have a text file with size 6.79 GB. Then i read it with code :-


f, err := os.Open("filepath")
checkErr(err)
// get the file size
stat, err := f.Stat()
checkErr(err)
buf := make([]byte, stat.Size())
fmt.Println(stat.Size())
f.Read(buf)


Finally i need to write the buffer as a new file with this code :-


ioutil.WriteFile("temp.csv", []byte(buf), 0644)


What did you expect to see?

I expect the new written file will the same size as the file i was read which size is 6.79GB.

What did you see instead?

The new written file size was 2.79GB.

@bradfitz
Copy link
Contributor

bradfitz commented Dec 4, 2017

It's not obvious that you're checking all your errors. I don't see error checks from your ioutil.WriteFile.

Oh, and you're also not using io.Reader correctly. See the docs on the https://golang.org/pkg/io/#Reader

For questions about Go, see https://golang.org/wiki/Questions.

@bradfitz bradfitz closed this as completed Dec 4, 2017
@golang golang locked and limited conversation to collaborators Dec 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants