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/error-handling/main.go
Normal file
24
best-practices/error-handling/main.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
f, err := os.OpenFile("test.txt", os.O_WRONLY, os.ModePerm)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
_, err = fmt.Fprintln(f, "Hello World")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
_, err = fmt.Fprintln(f, "Hello World")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(f)
|
||||
}
|
4
best-practices/error-handling/test.txt
Normal file
4
best-practices/error-handling/test.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Hello World
|
||||
Hello World
|
||||
Hello World
|
||||
Hello World
|
Reference in New Issue
Block a user