mirror of
https://github.com/mudabbir-ahmad/LearningGo.git
synced 2026-10-07 17:50:20 +00:00
fixed nil
This commit is contained in:
1 parent
b2512bd39a
commit
16d9c8b171
1 file changed
+9
-1
@@ -7,9 +7,16 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func check(e error) {
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
}
|
||||
|
||||
func write(a, b string) {
|
||||
path := filepath.Join(a, b)
|
||||
file, _ := os.Create(path)
|
||||
file, err := os.Create(path)
|
||||
check(err)
|
||||
|
||||
file.Sync()
|
||||
|
||||
@@ -23,4 +30,5 @@ func main() {
|
||||
fmt.Println("Leanring go.")
|
||||
fmt.Println("Adding a function to create a file")
|
||||
write("./", "file.txt")
|
||||
fmt.Println("File created successfully. with contents inside")
|
||||
}
|
||||
Reference in new issue
Block a user