code-for-blog

module
v0.0.0-...-4b1676d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: Unlicense

README

This repository collects code samples linked from `my blog
<https://eli.thegreenplace.net>`_. Unless otherwise noted, all the code here is
in the public domain (see the ``LICENSE`` file in this repository for more
details).

I'm making this code available publicly in good faith; note that this does not
mean the code is supported in any way. I'm unlikely to provide significant
support for code in old articles, for example, because sometimes I no longer
have the environment required to run and test the code.

Directories

Path Synopsis
2016
go-suffixarray/src
Go suffixarray sample - basic usage of creation and lookup.
Go suffixarray sample - basic usage of creation and lookup.
2018
go-copying-mutex
Pointer receiver properly referring to mutex.
Pointer receiver properly referring to mutex.
goadt
Parser and evaluator for a simple calculator with variables.
Parser and evaluator for a simple calculator with variables.
threadoverhead
Ping ponging messages between two goroutines on a channel, measuring number of messages sent per second.
Ping ponging messages between two goroutines on a channel, measuring number of messages sent per second.
2019
aes-encrypt-file
Sample of encrypting and decrypting a buffer with crypto/aes.
Sample of encrypting and decrypting a buffer with crypto/aes.
github-hook-google-cloud-function
Simple payload server for Github hooks.
Simple payload server for Github hooks.
go-check-interface
Basic example that demonstrates a type that doesn't implement an interface being flagged for a compile error when assigned to the interface.
Basic example that demonstrates a type that doesn't implement an interface being flagged for a compile error when assigned to the interface.
gohttpconcurrency
This is a basic server that has race conditions.
This is a basic server that has race conditions.
gojsoncookbook
Decoding arbitrary nested maps from JSON using generic interface{}s.
Decoding arbitrary nested maps from JSON using generic interface{}s.
loopvar-goroutine
Closure capture of loop variables, forcing by-value capture with ii.
Closure capture of loop variables, forcing by-value capture with ii.
rwlocks
Implementation of several read-write locks in Go.
Implementation of several read-write locks in Go.
xml-stream
An example streaming XML parser using encoding/xml.
An example streaming XML parser using encoding/xml.
2020
go-json-complex-types
Sample code for unmarshaling complex JSON structures into Go structs, using several approaches.
Sample code for unmarshaling complex JSON structures into Go structs, using several approaches.
go-json-optional-fields
Custom unmarshaling of a JSON type to a map, in order to set defaults to missing keys.
Custom unmarshaling of a JSON type to a map, in order to set defaults to missing keys.
go-pubsub
PubSub implementation where Subscribe returns a channel.
PubSub implementation where Subscribe returns a channel.
go-testing-flags
Splitting flag parsing to a self contained function returning a Config.
Splitting flag parsing to a self contained function returning a Config.
tcp-server-shutdown/shutdown1
Socket server that can be shut down -- stop serving, in a graceful manner.
Socket server that can be shut down -- stop serving, in a graceful manner.
tcp-server-shutdown/shutdown2
Socket server that can be shut down -- stop serving, in a graceful manner.
Socket server that can be shut down -- stop serving, in a graceful manner.
2021
go-generic-slice
Examples of writing concrete (non-generic) functions on slices.
Examples of writing concrete (non-generic) functions on slices.
go-life-http-request
Basic server using the default mux.
Basic server using the default mux.
tls
Simple HTTPS client in Go with mTLS.
Simple HTTPS client in Go with mTLS.
tlssocket
TLS socket dialer, showing certificate chain of server.
TLS socket dialer, showing certificate chain of server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL