forked from varia/go-sh-manymanuals
example ls program
This commit is contained in:
parent
f06ddb4e29
commit
daac17e453
7
exp/README.md
Normal file
7
exp/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# exp
|
||||||
|
|
||||||
|
> WIP
|
||||||
|
|
||||||
|
## `ls.go`
|
||||||
|
|
||||||
|
Lists files in [`files`](./files/). Run with `go run ls.go`.
|
BIN
exp/files/arrestantenhandleiding.pdf
Normal file
BIN
exp/files/arrestantenhandleiding.pdf
Normal file
Binary file not shown.
BIN
exp/files/vanwiehuurik.pdf
Normal file
BIN
exp/files/vanwiehuurik.pdf
Normal file
Binary file not shown.
25
exp/ls.go
Normal file
25
exp/ls.go
Normal 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())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user