Dreams of Code Logo
Command Line Applications in Go
Introduction
7 lessons
Introduction to the course
02:58
Welcome!
04:56
Setting up your environment
15:27
Go 101: Variables, Values & Types
24:33
Go 101: Conditionals & Loops
19:26
Go 101: Functions & Pointers
17:09
Go 101: Packages
12:44
Counting Words
7 lessons
Starting a new project
12:41
Reading from a file
11:23
A Simple Word Counter
09:30
Writing tests
15:34
Edge cases
10:35
Table Driven Testing
13:11
A better algorithm
15:23
Input, Output, & Arguments
13 lessons
Introduction to input
02:19
Exit codes
05:39
Standard error
11:10
Reading large files
23:27
Bytes & ascii
15:12
Unicode & Runes
The bufio package
Decoupling & io.Reader
Command line arguments
Handling multiple errors
Closing files with defer
Standard input
Scanning data
Adding Features
15 lessons
Adding new features
Counting lines
Counting bytes
Encapsulation
File offsets and seeking
Methods
Variadic parameters
Method receivers
CLI flags
Single pass algorithm
Tabular output
Organizing our code
Package visibility
Constructor arguments
Whitebox vs Blackbox testing
Concurrency & Streams
7 lessons
Introduction to concurrency & data
Goroutines & Waitgroups
Channels
Handling async errors
io.TeeReader
io.Pipe
io.MultiWriter
Advanced Testing
8 lessons
Introduction to Advanced Testing
Benchmark testing
End to end testing (e2e)
e2e: Testing files
e2e: Multiple files
Determinstic output
e2e: Testing flags
Creating test helpers
Commands, Signals, & Contexts
11 lessons
Executing commands
Passing in input
Configuring commands
Asynchronous execution
Signals
Graceful shutdown
Cancellation
context.Context
Building a process guard
Opening an editor
Fuzzing finding with fzf
Filesystem & Networking
14 lessons
Introduction to Networking & Files
File flags
File permissions
Walking the filesystem
Lockfiles & PIDFiles
File locks
The net package
TCP Client
DNS lookups
Port scanning
The net/http package
Marshaling & unmarshaling data
Sending files with HTTP
Testing HTTP Requests
Powerful Command Line Applications
22 lessons
Introduction to Powerful CLI Apps
Subcommands
Flagsets
Subcommand Abstraction
Compressing files & data with GZip
Hashing files & data
Password & Secure Input
Have I been pwned?
Environment variables
Configuration files
Advanced Error Handling
Embedding Files
Cross platform code
Build flags
Regular expressions
UI: A Loading Spinner
UI: A Progress Bar
Adding color to Stdout
Working with images
Distributing an application
An Application Builder
Handling CGO
Popular CLI Packages
12 lessons
Introduction to Popular CLI packages
Subcommands with Cobra
POSIX flags with pFlag
Storing data with SQLite
Database Migrations with Migrate
Repositories with SQLc
Color with color
TUI with Bubble Tea
Forms with huh
Test assertions with Testify
Mocking with go-mock
Releasing with Go releaser
Final Project
Coming Soon
Introduction to Final Project
Coming Soon
Installing Ollama
Coming Soon
Obtaining staged changes
Coming Soon
Handling errors
Coming Soon
Performing HTTP Requests
Coming Soon
Adding in retry
Coming Soon
Interfaces
Coming Soon
Adding another provider
Coming Soon
Commiting our messages
Coming Soon
Introduction
7 lessons
Introduction to the course
02:58
Welcome!
04:56
Setting up your environment
15:27
Go 101: Variables, Values & Types
24:33
Go 101: Conditionals & Loops
19:26
Go 101: Functions & Pointers
17:09
Go 101: Packages
12:44
Counting Words
7 lessons
Starting a new project
12:41
Reading from a file
11:23
A Simple Word Counter
09:30
Writing tests
15:34
Edge cases
10:35
Table Driven Testing
13:11
A better algorithm
15:23
Input, Output, & Arguments
13 lessons
Introduction to input
02:19
Exit codes
05:39
Standard error
11:10
Reading large files
23:27
Bytes & ascii
15:12
Unicode & Runes
The bufio package
Decoupling & io.Reader
Command line arguments
Handling multiple errors
Closing files with defer
Standard input
Scanning data
Adding Features
15 lessons
Adding new features
Counting lines
Counting bytes
Encapsulation
File offsets and seeking
Methods
Variadic parameters
Method receivers
CLI flags
Single pass algorithm
Tabular output
Organizing our code
Package visibility
Constructor arguments
Whitebox vs Blackbox testing
Concurrency & Streams
7 lessons
Introduction to concurrency & data
Goroutines & Waitgroups
Channels
Handling async errors
io.TeeReader
io.Pipe
io.MultiWriter
Advanced Testing
8 lessons
Introduction to Advanced Testing
Benchmark testing
End to end testing (e2e)
e2e: Testing files
e2e: Multiple files
Determinstic output
e2e: Testing flags
Creating test helpers
Commands, Signals, & Contexts
11 lessons
Executing commands
Passing in input
Configuring commands
Asynchronous execution
Signals
Graceful shutdown
Cancellation
context.Context
Building a process guard
Opening an editor
Fuzzing finding with fzf
Filesystem & Networking
14 lessons
Introduction to Networking & Files
File flags
File permissions
Walking the filesystem
Lockfiles & PIDFiles
File locks
The net package
TCP Client
DNS lookups
Port scanning
The net/http package
Marshaling & unmarshaling data
Sending files with HTTP
Testing HTTP Requests
Powerful Command Line Applications
22 lessons
Introduction to Powerful CLI Apps
Subcommands
Flagsets
Subcommand Abstraction
Compressing files & data with GZip
Hashing files & data
Password & Secure Input
Have I been pwned?
Environment variables
Configuration files
Advanced Error Handling
Embedding Files
Cross platform code
Build flags
Regular expressions
UI: A Loading Spinner
UI: A Progress Bar
Adding color to Stdout
Working with images
Distributing an application
An Application Builder
Handling CGO
Popular CLI Packages
12 lessons
Introduction to Popular CLI packages
Subcommands with Cobra
POSIX flags with pFlag
Storing data with SQLite
Database Migrations with Migrate
Repositories with SQLc
Color with color
TUI with Bubble Tea
Forms with huh
Test assertions with Testify
Mocking with go-mock
Releasing with Go releaser
Final Project
Coming Soon
Introduction to Final Project
Coming Soon
Installing Ollama
Coming Soon
Obtaining staged changes
Coming Soon
Handling errors
Coming Soon
Performing HTTP Requests
Coming Soon
Adding in retry
Coming Soon
Interfaces
Coming Soon
Adding another provider
Coming Soon
Commiting our messages
Coming Soon
/
/
  1. Command Line Applications in Go
  2. Adding Features
  3. Counting lines
Dreams of Code Logo
Video thumbnail
Locked video

Please purchase the course to watch this video.

Adding Features
Counting lines

Full Course

$299$199
USD
EARLY BIRD OFFER!
The implementation of a `count_lines` function in Go enhances functionality by allowing developers to count the number of newline characters within an `io.Reader`, a common task when processing text files. Utilizing a Test-Driven Development (TDD) approach, a series of test cases are created first, including scenarios for simple inputs, edge cases like empty files, and inputs without trailing newlines. Initially, a `bufio.Scanner` is employed, but it proves inadequate due to its inherent behavior of counting lines regardless of newlines. Thus, the solution shifts to using a `bufio.Reader`, reading individual runes to accurately tally the newline characters. This adaptive methodology not only reinforces the reliability of the implementation but also makes it clear how effective testing can guide development and ensure functionality aligns with intended outcomes.