Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Create-a-file/Go/create-a-file.go
Normal file
32
Task/Create-a-file/Go/create-a-file.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func createFile(fn string) {
|
||||
f, err := os.Create(fn)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println("file", fn, "created!")
|
||||
f.Close()
|
||||
}
|
||||
|
||||
func createDir(dn string) {
|
||||
err := os.Mkdir(dn, 0666)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println("directory", dn, "created!")
|
||||
}
|
||||
|
||||
func main() {
|
||||
createFile("input.txt")
|
||||
createFile("/input.txt")
|
||||
createDir("docs")
|
||||
createDir("/docs")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue