mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-08-03 05:02:16 +02:00
initial import
This commit is contained in:
24
best-practices/file-io/main.go
Normal file
24
best-practices/file-io/main.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
bites, err := ioutil.ReadFile("test.txt")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", bites)
|
||||
fmt.Println(string(bites))
|
||||
|
||||
toWrite := []byte("Hello World!")
|
||||
err = ioutil.WriteFile("test2.txt", toWrite, 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
1
best-practices/file-io/test.txt
Normal file
1
best-practices/file-io/test.txt
Normal file
@ -0,0 +1 @@
|
||||
Hello World!
|
Reference in New Issue
Block a user