example ls program

This commit is contained in:
decentral1se 2022-04-20 12:59:33 +02:00
parent f06ddb4e29
commit daac17e453
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410
4 changed files with 32 additions and 0 deletions

7
exp/README.md Normal file
View File

@ -0,0 +1,7 @@
# exp
> WIP
## `ls.go`
Lists files in [`files`](./files/). Run with `go run ls.go`.

Binary file not shown.

BIN
exp/files/vanwiehuurik.pdf Normal file

Binary file not shown.

25
exp/ls.go Normal file
View File

@ -0,0 +1,25 @@
package main
import (
"fmt"
"io/ioutil"
"log"
"path/filepath"
)
func main() {
fpath, err := filepath.Abs("./files")
if err != nil {
log.Fatalln(err)
}
files, err := ioutil.ReadDir(fpath)
if err != nil {
log.Fatalln(err)
}
for _, file := range files {
fmt.Println(file.Name())
}
}