Documentation ¶
Overview ¶
Package gokatas contains programming katas for memorizing and perfecting your Go movements. Katas are brief, well written Go programs.
Here's a typical practice cycle:
go run cmd/gokatas.go -c 2 # what kata should I practice today code . # understand, delete and try to write the code back vi katas.md # write down katas you've done (go doc KatasFile)
Index ¶
Constants ¶
View Source
const KatasFile = "katas.md"
KatasFile is a MarkDown file to track katas you've done. It looks like this:
- 2022-09-13: boring/boring, boring/channel
- 2022-09-10: areader
Variables ¶
This section is empty.
Functions ¶
Types ¶
Directories ¶
Path | Synopsis |
---|---|
Package areader implements io.Reader with a type that emits an infinite stream of the ASCII character 'A'.
|
Package areader implements io.Reader with a type that emits an infinite stream of the ASCII character 'A'. |
cmd
Areader reads three bytes from A into a slice.
|
Areader reads three bytes from A into a slice. |
Package battery gets MacBook battery status.
|
Package battery gets MacBook battery status. |
Boring contains various Go concurrency patterns in the form of boring conversations.
|
Boring contains various Go concurrency patterns in the form of boring conversations. |
channel
A channel allows for communication and synchronization between goroutines.
|
A channel allows for communication and synchronization between goroutines. |
generator
Generator is a function that returns a channel.
|
Generator is a function that returns a channel. |
lockstep
Lockstep makes Ann and Joe talk in lockstep (one after another).
|
Lockstep makes Ann and Joe talk in lockstep (one after another). |
multiplex
Multiplex lets talk Ann or Joe (whosever is ready) using fanIn function.
|
Multiplex lets talk Ann or Joe (whosever is ready) using fanIn function. |
select
Select statement is another way to handle multiple channels.
|
Select statement is another way to handle multiple channels. |
selectquit
Use quit channel to stop the conversation.
|
Use quit channel to stop the conversation. |
Bytecounter shows how to use interfaces.
|
Bytecounter shows how to use interfaces. |
Clock2 is a TCP server that periodically writes the time.
|
Clock2 is a TCP server that periodically writes the time. |
Print statistics about katas you've done.
|
Print statistics about katas you've done. |
Package compress compresses files.
|
Package compress compresses files. |
cmd
Compress files concurrently using a wait group.
|
Compress files concurrently using a wait group. |
Package cookie writes and reads a (not signed and not encrypted) HTTP [cookie].
|
Package cookie writes and reads a (not signed and not encrypted) HTTP [cookie]. |
cmd
Web server that sets a cookie and shows that client sent it back.
|
Web server that sets a cookie and shows that client sent it back. |
Package count2 counts lines in input.
|
Package count2 counts lines in input. |
Package count3 uses "functional options" pattern to set zero or more options.
|
Package count3 uses "functional options" pattern to set zero or more options. |
Package count5 accepts input also from one or more files supplied as command line arguments.
|
Package count5 accepts input also from one or more files supplied as command line arguments. |
Package counter implements an integer counter that can only be incremented.
|
Package counter implements an integer counter that can only be incremented. |
cmd
Counter creates an integer counter, increments it, prints it and resets it.
|
Counter creates an integer counter, increments it, prints it and resets it. |
Package countgo counts files with extension ".go" in fs.FS.
|
Package countgo counts files with extension ".go" in fs.FS. |
cmd
Countgo counts files with .go extension in supplied directory or in ".".
|
Countgo counts files with .go extension in supplied directory or in ".". |
Cryptopals shows basic crypto operations.
|
Cryptopals shows basic crypto operations. |
Dirs shows how to work with filesystem directories.
|
Dirs shows how to work with filesystem directories. |
Dup2 prints the count and text of lines that appear more than once in the input.
|
Dup2 prints the count and text of lines that appear more than once in the input. |
Dup3 prints the count and text of lines that appear more than once in the named input files.
|
Dup3 prints the count and text of lines that appear more than once in the named input files. |
Echo prints its command-line arguments.
|
Echo prints its command-line arguments. |
Echosrv is a web server that echoes the path component of the URL.
|
Echosrv is a web server that echoes the path component of the URL. |
Package enum shows idiomatic way to implement an enumerated type:
|
Package enum shows idiomatic way to implement an enumerated type: |
cmd
Enum shows how to use enumerated type.
|
Enum shows how to use enumerated type. |
Fetch prints content found at URLs defined as command line arguments.
|
Fetch prints content found at URLs defined as command line arguments. |
Fetchall ranges over the CLI arguments (that should be URLs) and fetches each of them.
|
Fetchall ranges over the CLI arguments (that should be URLs) and fetches each of them. |
Fibchan implements a function that returns a channel generating Fibonacci sequence.
|
Fibchan implements a function that returns a channel generating Fibonacci sequence. |
Fibfunc implements a function that returns a function (a closure) generating Fibonacci sequence.
|
Fibfunc implements a function that returns a function (a closure) generating Fibonacci sequence. |
Fibspin calculates 46th number from the Fibonacci sequence.
|
Fibspin calculates 46th number from the Fibonacci sequence. |
Findlinks2 does an HTTP GET on each URL, parses the result as HTML, and prints the links within it.
|
Findlinks2 does an HTTP GET on each URL, parses the result as HTML, and prints the links within it. |
Generics shows the basics of generics.
|
Generics shows the basics of generics. |
Package geometry defines simple types for plane geometry.
|
Package geometry defines simple types for plane geometry. |
Google is a toy search engine using the Go concurrency patterns from the boring folder.
|
Google is a toy search engine using the Go concurrency patterns from the boring folder. |
v2.0
V2.0 runs the three kinds of search concurrently using the fan-in pattern.
|
V2.0 runs the three kinds of search concurrently using the fan-in pattern. |
v2.1
V2.1 times out the search after 80ms using the timeout pattern.
|
V2.1 times out the search after 80ms using the timeout pattern. |
v3.0
V3.0 introduces replication.
|
V3.0 introduces replication. |
Package kv implements key-value store that persists data to disk.
|
Package kv implements key-value store that persists data to disk. |
Package logger uses channels to implement non-blocking logging.
|
Package logger uses channels to implement non-blocking logging. |
cmd
Log handles logging gracefully.
|
Log handles logging gracefully. |
Myprint shows how come fmt.Print can print (any number of) arguments of any type.
|
Myprint shows how come fmt.Print can print (any number of) arguments of any type. |
Netcat1 is a read-only TCP client.
|
Netcat1 is a read-only TCP client. |
Netcat2 is a read/write TCP client.
|
Netcat2 is a read/write TCP client. |
Noescape shows how to suppress html/template auto-escaping behavior for fields that contain trusted HTML data.
|
Noescape shows how to suppress html/template auto-escaping behavior for fields that contain trusted HTML data. |
Package older finds files older than a given duration.
|
Package older finds files older than a given duration. |
Outline prints the structure of the HTML node tree supplied on STDIN.
|
Outline prints the structure of the HTML node tree supplied on STDIN. |
Panic describes and shows how panic and defer work.
|
Panic describes and shows how panic and defer work. |
Parsejson parses a JSON string and prints it out.
|
Parsejson parses a JSON string and prints it out. |
Pingpong shows how (un-buffered) channels are used for communication and synchronization between goroutines.
|
Pingpong shows how (un-buffered) channels are used for communication and synchronization between goroutines. |
https://github.com/jreisinger/homepage/blob/master/notes/go/pointers.md
|
https://github.com/jreisinger/homepage/blob/master/notes/go/pointers.md |
Primesieve is a concurrent prime sieve.
|
Primesieve is a concurrent prime sieve. |
Package promyaml shows how to get (Prometheus) configuration from YAML file.
|
Package promyaml shows how to get (Prometheus) configuration from YAML file. |
Proxy is a simple proxy that mediates TCP traffic between client and upstream.
|
Proxy is a simple proxy that mediates TCP traffic between client and upstream. |
Package repike is a Go [rewrite] of Rob Pike's regex [matcher] that handles:
|
Package repike is a Go [rewrite] of Rob Pike's regex [matcher] that handles: |
Package reverse reverses a string.
|
Package reverse reverses a string. |
Package rot13 implements an io.Reader that reads from an io.Reader, modifying the stream by applying the rot13 algorithm to it.
|
Package rot13 implements an io.Reader that reads from an io.Reader, modifying the stream by applying the rot13 algorithm to it. |
cmd
Decode message encoded with rot13 cipher.
|
Decode message encoded with rot13 cipher. |
Package search implements linear and binary search algorithms.
|
Package search implements linear and binary search algorithms. |
Shop4 is a web shop selling shoes and socks.
|
Shop4 is a web shop selling shoes and socks. |
https://github.com/jreisinger/homepage/blob/master/notes/go/slices.md
|
https://github.com/jreisinger/homepage/blob/master/notes/go/slices.md |
Sortbooks sorts a collection of books.
|
Sortbooks sorts a collection of books. |
Package sqrt calculates square root: given number x, we want to find the number z for which z² is most nearly x.
|
Package sqrt calculates square root: given number x, we want to find the number z for which z² is most nearly x. |
Package sum sums a list of integers using loop and divide-and-conquer technique.
|
Package sum sums a list of integers using loop and divide-and-conquer technique. |
Sample functions using switch statement.
|
Sample functions using switch statement. |
Tcpscanner reports open TCP ports on a host.
|
Tcpscanner reports open TCP ports on a host. |
Package thumb explores three common concurrency patterns for executing all the iterations of a loop in parallel.
|
Package thumb explores three common concurrency patterns for executing all the iterations of a loop in parallel. |
cmd
Thumb generates thumbnails for the supplied JPEG pictures.
|
Thumb generates thumbnails for the supplied JPEG pictures. |
The thumbnail package produces thumbnail-size images from larger images.
|
The thumbnail package produces thumbnail-size images from larger images. |
Tictactoe creates a a tic-tac-toe board as a slice of string slices.
|
Tictactoe creates a a tic-tac-toe board as a slice of string slices. |
Timer times out a goroutine that emits Go pointer types over a channel.
|
Timer times out a goroutine that emits Go pointer types over a channel. |
Package weather shows how to build an API client.
|
Package weather shows how to build an API client. |
Package word provides utilities for word games.
|
Package word provides utilities for word games. |
Package write shows how to write programs manipulating files with test-first approach (TDD).
|
Package write shows how to write programs manipulating files with test-first approach (TDD). |
Package z takes lines from stdin, makes them into tasks that get processed and printed.
|
Package z takes lines from stdin, makes them into tasks that get processed and printed. |
lookup-v1
A faster version of lookup-v0.sh that handles errors and can be generalized.
|
A faster version of lookup-v0.sh that handles errors and can be generalized. |
lookup-v2
Lookup version that uses z package.
|
Lookup version that uses z package. |
Click to show internal directories.
Click to hide internal directories.