Sign in

Chances are if you’ve written some go or delved into a well-maintained go project, you’ve seen structs with an underscore field:

type ListTablesInput struct {
_ struct{} `type:"structure"`
ExclusiveStartTableName *string `min:"3" type:"string" Limit *int64 `min:"1" type:"integer"`


The purpose behind using the _ field on a struct is to enforce keyed fields when initializing a struct.

input := ListTablesInput{
ExclusiveStartTableName: "table-name",
Limit: 100,
// instead of
input := ListTablesInput{"table-name", 100}

If you attempt to initialize a struct without the field names, you will get an error along the lines of `cannot use as type struct {} in…

  1. given a composite index, make sure the order of your index is in line with your access pattern. you do not want the following

If you’ve ever seen something like this and wondered what the hell this means you’re in luck.

An SQL index lookup requires (1) the tree traversal (2) following the linked list node chain (3) fetching the table data. In step (1) a query will traverse a B-tree to quickly find the page that holds the row(s). The rows themselves are nodes in a doubly linked list and the database will perform step (2) to find all entries that match the key. And lastly the database will use the row IDs found to get the records themselves.

Bitmap Index Scan means…


  • Boxes are individual squares
  • Units are complete rows, columns, and 3x3 squares
  • Peers are boxes that belong to the same unit
rows = 'ABCDEFGHI'
cols = '123456789'
def cross(a, b):
# output = []
# for s in a:
# for t in b:
# output.append(s+t)
# return output
return [s+t for s in a for t in b]
boxes = cross(rows, cols)
row_units = [cross(r, cols) for r in rows]
column_units = [cross(rows, c) for c in cols]
square_units = [cross(rs, cs) for rs in ('ABC','DEF','GHI') for cs in ('123','456','789')]
unitlist = row_units + column_units + square_units
units = dict((s, [u for u…

$ brew tap universal-ctags/universal-ctags$ brew install --HEAD universal-ctags$ alias ctags=“`brew —-prefix`/bin/ctags”

Using tags is a powerful tool to be able to jump to the definition of a function, variable, or class in Vim. Install universal-ctags and alias it as ctags. This allows adding support for languages that are not supported out of the box by universal-ctags (such as golang).

Add the following lines to your .ctags file to support golang:

--regex-golang=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/f,func/
--regex-golang=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/v,var/

Now you can generate tags for source files:

$ ctags -R .

Open up a file in vim and use Ctrl + ] to jump to the definition of whatever is on your cursor and Ctrl + t to go back.

:help ctags # for more information and tips

Supported ctags languages

Most times when writing software, you use other software or as we call them “dependencies.” In golang, we may call that a collection of go packages. That collection of go packages is outlined in a file called go.mod.

module ( v1.13.3 // v0.5.0 // v0.0.0-20191202143827-86a70503ff7e // v0.0.0-20191125180803-fdd1cda4f05f // v0.0.0-20191126235420-ef20fe5d7933 // v0.0.0-20191128015809-6d18c012aee9 // v0.0.0-20191024005414-555d28b269f0 // v0.0.0-20191202203127-2b6af5f9ace7 // v0.0.0-20191115221424-83cc0476cb11 // v2.4.0 // v2.2.7 …

Chinese Finger Trap
func Google(query string) (results []string) {
c := make(chan string)

go func() {
c <- Web(query)
go func() {
c <- Image(query)
go func() {
c <- Video(query)
timeout := time.After(80 * time.Millisecond)
for i := 0; i < 3; i++ {
select {
case result := <-c:
results = append(results, result)
case <-timeout:
fmt.Println("timed out")

Let’s take a look at an example from Google I/O talk given by Rob Pike. …

type Result struct {
Item item
Error error
ch := make(chan Result)var wg sync.WaitGroupfor _, i:= range items { go func(i Item) {
defer wg.Done()

res, err := processItem(i)
if err != nil {
ch <- Result{Item: i, Error: err}
ch <- Result{Item: res, Error: err}
go func() {
var successful, failed []Itemfor r := range ch {
if r.Error != nil {
failed = append(failed, r.Item)
succeeded = append(succeeded, r.Item)

Asynchronously wg.Wait(), so that the channel values are processed and appended to appropriate slices without…

Photo by Alice on Unsplash

If you’ve been to China or have Chinese friends you know that WeChat is used for just about anything in China. WeChat has an estimated 900 million monthly active users and the vast majority of the country uses WeChat Pay. WeChat Pay allows users to pay virtually anything with the money linked to their WeChat. This is more than just your usual Apple Pay, because unlike America where every store that wants to adopt Apple Pay needs a corresponding point of sale system, Chinese vendors can use an offline QR code linked to WeChat and bank account.

This is great…

Paul Yeo

disscepolo della sperientia

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store