- I generate numbers from 0 to 10
- I create a file
- And I try to write to the file by converting integers to string
But when I open the h.txt file there is nothing written
How to fix this and have the numbers written to the h.txt file?
package main
import "os"
func main() {
for i := 0; i < 10; i++ { // Generating...
f, _ := os.Create("h.txt") // creating...
f.WriteString(string(i)) // writing...
defer f.Close()
}
}
Thanks!