Documentation
¶
Overview ¶
Package babygo carries the exercise set inside the binary.
It exists at the repo root for one boring reason: //go:embed cannot reach above its own directory, and exercises/ and solutions/ have to stay at the root so that a clone of this repo is itself a usable workspace. Everything that reads these bytes lives in internal/workspace and takes an fs.FS, so it can be tested against a fake tree instead of all 85 real ones.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Assets embed.FS
Assets is the exercise set as it shipped: exercises/<slug>/… and solutions/<slug>/…, byte for byte what was in the tree this binary was built from.
The all: prefix is belt and braces. Nothing in the set starts with "." or "_" today, but an exercise about dotfiles is an obvious thing to write, and it would go missing from every installed copy without a word of warning.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
babygo
command
Command babygo is a rustlings-style exercise runner for Go by Example.
|
Command babygo is a rustlings-style exercise runner for Go by Example. |
|
exercises
|
|
|
01_hello-world
command
Our first program will print the classic "hello world" message.
|
Our first program will print the classic "hello world" message. |
|
02_values
command
|
|
|
03_variables
command
|
|
|
04_constants
command
|
|
|
05_for
command
|
|
|
06_if-else
command
|
|
|
07_switch
command
|
|
|
08_arrays
command
|
|
|
09_slices
command
|
|
|
10_maps
command
|
|
|
11_functions
command
|
|
|
12_multiple-return-values
command
|
|
|
13_variadic-functions
command
|
|
|
14_closures
command
|
|
|
15_recursion
command
|
|
|
16_range-over-built-in-types
command
|
|
|
17_pointers
command
|
|
|
18_strings-and-runes
command
|
|
|
19_structs
command
|
|
|
20_methods
command
|
|
|
21_interfaces
command
|
|
|
22_enums
command
|
|
|
23_struct-embedding
command
|
|
|
24_generics
command
|
|
|
25_range-over-iterators
command
|
|
|
26_errors
command
|
|
|
27_custom-errors
command
|
|
|
28_goroutines
command
|
|
|
29_channels
command
|
|
|
30_channel-buffering
command
|
|
|
31_channel-synchronization
command
|
|
|
32_channel-directions
command
|
|
|
33_select
command
|
|
|
34_timeouts
command
|
|
|
36_closing-channels
command
|
|
|
37_range-over-channels
command
|
|
|
38_timers
command
|
|
|
39_tickers
command
|
|
|
40_worker-pools
command
|
|
|
41_waitgroups
command
|
|
|
42_rate-limiting
command
|
|
|
43_atomic-counters
command
|
|
|
44_mutexes
command
|
|
|
45_stateful-goroutines
command
|
|
|
46_sorting
command
|
|
|
47_sorting-by-functions
command
|
|
|
48_panic
command
|
|
|
49_defer
command
|
|
|
50_recover
command
|
|
|
51_string-functions
command
|
|
|
52_string-formatting
command
|
|
|
53_text-templates
command
|
|
|
54_regular-expressions
command
|
|
|
55_json
command
|
|
|
56_xml
command
|
|
|
57_time
command
|
|
|
58_epoch
command
|
|
|
59_time-formatting-parsing
command
|
|
|
60_random-numbers
command
|
|
|
61_number-parsing
command
|
|
|
62_url-parsing
command
|
|
|
63_sha256-hashes
command
|
|
|
64_base64-encoding
command
|
|
|
65_reading-files
command
|
|
|
66_writing-files
command
|
|
|
67_line-filters
command
Here's an example line filter in Go that writes a capitalized version of all input text.
|
Here's an example line filter in Go that writes a capitalized version of all input text. |
|
68_file-paths
command
The `filepath` package provides functions to parse and construct *file paths* in a way that is portable between operating systems; `dir/file` on Linux vs.
|
The `filepath` package provides functions to parse and construct *file paths* in a way that is portable between operating systems; `dir/file` on Linux vs. |
|
69_directories
command
|
|
|
71_embed-directive
command
`//go:embed` is a [compiler directive](https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives) that allows programs to include arbitrary files and folders in the Go binary at build time.
|
`//go:embed` is a [compiler directive](https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives) that allows programs to include arbitrary files and folders in the Go binary at build time. |
|
73_command-line-arguments
command
|
|
|
74_command-line-flags
command
|
|
|
75_command-line-subcommands
command
|
|
|
76_environment-variables
command
|
|
|
77_logging
command
The Go standard library provides straightforward tools for outputting logs from Go programs, with the log(https://pkg.go.dev/log) package for free-form output and the log/slog(https://pkg.go.dev/log/slog) package for structured output.
|
The Go standard library provides straightforward tools for outputting logs from Go programs, with the log(https://pkg.go.dev/log) package for free-form output and the log/slog(https://pkg.go.dev/log/slog) package for structured output. |
|
78_http-client
command
The Go standard library comes with excellent support for HTTP clients and servers in the `net/http` package.
|
The Go standard library comes with excellent support for HTTP clients and servers in the `net/http` package. |
|
79_http-server
command
Writing a basic HTTP server is easy using the `net/http` package.
|
Writing a basic HTTP server is easy using the `net/http` package. |
|
80_tcp-server
command
The `net` package provides the tools we need to easily build TCP socket servers.
|
The `net` package provides the tools we need to easily build TCP socket servers. |
|
81_context
command
In the previous example we looked at setting up a simple [HTTP server](http-server).
|
In the previous example we looked at setting up a simple [HTTP server](http-server). |
|
82_spawning-processes
command
|
|
|
83_execing-processes
command
|
|
|
84_signals
command
|
|
|
85_exit
command
|
|
|
internal
|
|
|
exercise
Package exercise loads the exercise set from disk.
|
Package exercise loads the exercise set from disk. |
|
progress
Package progress tracks which exercises are solved.
|
Package progress tracks which exercises are solved. |
|
upstream
Package upstream reads a checkout of Go by Example.
|
Package upstream reads a checkout of Go by Example. |
|
verify
Package verify decides whether an exercise is solved.
|
Package verify decides whether an exercise is solved. |
|
workspace
Package workspace creates and maintains the directory a learner works in.
|
Package workspace creates and maintains the directory a learner works in. |
|
solutions
|
|
|
01_hello-world
command
Our first program will print the classic "hello world" message.
|
Our first program will print the classic "hello world" message. |
|
02_values
command
|
|
|
03_variables
command
|
|
|
04_constants
command
|
|
|
05_for
command
|
|
|
06_if-else
command
|
|
|
07_switch
command
|
|
|
08_arrays
command
|
|
|
09_slices
command
|
|
|
10_maps
command
|
|
|
11_functions
command
|
|
|
12_multiple-return-values
command
|
|
|
13_variadic-functions
command
|
|
|
14_closures
command
|
|
|
15_recursion
command
|
|
|
16_range-over-built-in-types
command
|
|
|
17_pointers
command
|
|
|
18_strings-and-runes
command
|
|
|
19_structs
command
|
|
|
20_methods
command
|
|
|
21_interfaces
command
|
|
|
22_enums
command
|
|
|
23_struct-embedding
command
|
|
|
24_generics
command
|
|
|
25_range-over-iterators
command
|
|
|
26_errors
command
|
|
|
27_custom-errors
command
|
|
|
28_goroutines
command
|
|
|
29_channels
command
|
|
|
30_channel-buffering
command
|
|
|
31_channel-synchronization
command
|
|
|
32_channel-directions
command
|
|
|
33_select
command
|
|
|
34_timeouts
command
|
|
|
36_closing-channels
command
|
|
|
37_range-over-channels
command
|
|
|
38_timers
command
|
|
|
39_tickers
command
|
|
|
40_worker-pools
command
|
|
|
41_waitgroups
command
|
|
|
42_rate-limiting
command
|
|
|
43_atomic-counters
command
|
|
|
44_mutexes
command
|
|
|
45_stateful-goroutines
command
|
|
|
46_sorting
command
|
|
|
47_sorting-by-functions
command
|
|
|
48_panic
command
|
|
|
49_defer
command
|
|
|
50_recover
command
|
|
|
51_string-functions
command
|
|
|
52_string-formatting
command
|
|
|
53_text-templates
command
|
|
|
54_regular-expressions
command
|
|
|
55_json
command
|
|
|
56_xml
command
|
|
|
57_time
command
|
|
|
58_epoch
command
|
|
|
59_time-formatting-parsing
command
|
|
|
60_random-numbers
command
|
|
|
61_number-parsing
command
|
|
|
62_url-parsing
command
|
|
|
63_sha256-hashes
command
|
|
|
64_base64-encoding
command
|
|
|
65_reading-files
command
|
|
|
66_writing-files
command
|
|
|
67_line-filters
command
Here's an example line filter in Go that writes a capitalized version of all input text.
|
Here's an example line filter in Go that writes a capitalized version of all input text. |
|
68_file-paths
command
The `filepath` package provides functions to parse and construct *file paths* in a way that is portable between operating systems; `dir/file` on Linux vs.
|
The `filepath` package provides functions to parse and construct *file paths* in a way that is portable between operating systems; `dir/file` on Linux vs. |
|
69_directories
command
|
|
|
71_embed-directive
command
`//go:embed` is a [compiler directive](https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives) that allows programs to include arbitrary files and folders in the Go binary at build time.
|
`//go:embed` is a [compiler directive](https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives) that allows programs to include arbitrary files and folders in the Go binary at build time. |
|
73_command-line-arguments
command
|
|
|
74_command-line-flags
command
|
|
|
75_command-line-subcommands
command
|
|
|
76_environment-variables
command
|
|
|
77_logging
command
The Go standard library provides straightforward tools for outputting logs from Go programs, with the log(https://pkg.go.dev/log) package for free-form output and the log/slog(https://pkg.go.dev/log/slog) package for structured output.
|
The Go standard library provides straightforward tools for outputting logs from Go programs, with the log(https://pkg.go.dev/log) package for free-form output and the log/slog(https://pkg.go.dev/log/slog) package for structured output. |
|
78_http-client
command
The Go standard library comes with excellent support for HTTP clients and servers in the `net/http` package.
|
The Go standard library comes with excellent support for HTTP clients and servers in the `net/http` package. |
|
79_http-server
command
Writing a basic HTTP server is easy using the `net/http` package.
|
Writing a basic HTTP server is easy using the `net/http` package. |
|
80_tcp-server
command
The `net` package provides the tools we need to easily build TCP socket servers.
|
The `net` package provides the tools we need to easily build TCP socket servers. |
|
81_context
command
In the previous example we looked at setting up a simple [HTTP server](http-server).
|
In the previous example we looked at setting up a simple [HTTP server](http-server). |
|
82_spawning-processes
command
|
|
|
83_execing-processes
command
|
|
|
84_signals
command
|
|
|
85_exit
command
|