Skip to content

Commit c8c4602

Browse files
committed
further docs
1 parent 3f699d5 commit c8c4602

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

cli-files/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ If you smash through this, here's some fun/tricky extensions:
154154
- `cobra-cli init .`
155155
- look at all the files
156156
- `go install . && go-cat`
157+
- set up a command that takes an argument, opens the file and prints it out (`os.ReadFile`, `os.Stdout.Write`)
158+
- handle the error if you pass a directory like cat does
157159

158160
[go]: https://go.dev/
159161
[cat]: https://en.m.wikipedia.org/wiki/Cat_(Unix)

cli-files/go-cat/cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ func NewRoodCmd() *cobra.Command {
3535
return fmt.Errorf("go-cat: %s: Is a directory", path)
3636
}
3737

38+
// Read the data from the file
39+
// https://pkg.go.dev/os#ReadFile
3840
data, err := os.ReadFile(path)
3941
if err != nil {
4042
return err

0 commit comments

Comments
 (0)