Exercise: Solve this exercise in Go with test cases.
Tree exerciseLabels: Intermediate
Time to complete: 4-5 days
What will you learn:
- Basics of CLI building in Go, parsing CLI flags, cobra library
- Reading nested directories, computing stats from a directory structure
- Writing table-driven tests
- Tree data structure and how to represent that in Go code
- Converting a struct into custom JSON and XML format (when implementing the last few stories of the problem statement)
How to evaluate your solution:
Actual Solution:
- Donโt look at the solution unless you have you. Otherwise, youโre not getting much value from the bootcamp.
I know what I am doing; stop patronizing me.
- If you say so ๐คท, hereโs the sample implementation - https://github.com/RamanaReddy0M/go-examples/tree/master/tree-problem
Resources:
- Just for func series on Youtube - https://www.youtube.com/c/JustForFunc, especially the tree video - https://www.youtube.com/watch?v=XbKSssBftLM
- Writing command line applications in Go https://learning.oreilly.com/library/view/practical-go/9781119773818/c01.xhtml read Chapter 1 from this Practical Go book.
- filepath.Walk documentation - https://pkg.go.dev/path/filepath#Walk