
2 min read
Primary expressions
Today we just have the definition of a term. We’ll be building on this term in the following days. Primary expressions Primary expressions are the operands for unary and binary expressions. PrimaryExpr = Operand | Conversion | MethodExpr | PrimaryExpr Selector | PrimaryExpr Index | PrimaryExpr Slice | PrimaryExpr TypeAssertion | PrimaryExpr Arguments . Selector = "." identifier . Index = "[" Expression [ "," ] "]" . Slice = "[" [ Expression ] ":" [ Expression ] "]" | "[" [ Expression ] ":" Expression ":" Expression "]" .

2 min read
Closures
Today I’m live streaming again at the regular time. Last week I missed, due to some hardware problems. But I’m back up and running! Join me as I go through boot.dev’s “Learn Web Servers” course that I had planned for last week. I hope you can join me Closures are a common concept in many langauges. If you’ve used them before, there’s nothing really new or interesting about the way Go handles them.

2 min read
Function literals
This week’s episode of the Cup o’ Go podcast is out! Check out the latest Go news, and an interview with Tim Stiles about hacking 🧬 DNA with Go. We should all be familiar with functions, and how to create them in Go: func Foo() { /* ... */ } But we can also have function literals… Function literals A function literal represents an anonymous function. Function literals cannot declare type parameters.

3 min read
(Bad) examples of valid composite literals
Today we round out the spec’s discussion of composite literals, with a few examples. Including some bad ones. 🤷 Composite literals … Examples of valid array, slice, and map literals: // list of prime numbers primes := []int{2, 3, 5, 7, 9, 2147483647} // vowels[ch] is true if ch is a vowel vowels := [128]bool{'a': true, 'e': true, 'i': true, 'o': true, 'u': true, 'y': true} // the array [10]float32{-1, 0, 0, 0, -0.
Subscribe to Boldly Go: Daily
Every day I'll send you advice to improve your understanding of Go. Don't miss out! I will respect your inbox, and honor my privacy policy.
Unsure? Browse the archive.

2 min read
Ambiguous composite literals
I had planned to live stream this afternoon, but ran into some hardware problems that left me scrambling to get my PC booting again. It is now booting, and barring any other unforseen complications, I’ll be doing the planned boot.dev’s “Learn Web Servers” course next week at the regular time. I hope you can join me Here’s one of the bits of the Go spec you probably never knew existed (I didn’t), and will never need to care about.
29 min watch
Go Code Roast: Secret Hitler Game
Watch as I review a simple game, writte in Go, and explain what I like, what I don't like, and how the author could improve his chances of landing a job by showing off this code.

2 min read
Nesting composite literals
ReminderMonday I’ll be building a Go web server during my weekly live stream, following boot.dev’s “Learn Web Servers” course. I hope you can join me Composite literals … Within a composite literal of array, slice, or map type T, elements or map keys that are themselves composite literals may elide the respective literal type if it is identical to the element or key type of T. Similarly, elements or keys that are addresses of composite literals may elide the &T when the element or key type is *T.

2 min read
Slice literals
ReminderMonday I’ll be building a Go web server during my weekly live stream, following boot.dev’s “Learn Web Servers” course. I hope you can join me Composite literals … A slice literal describes the entire underlying array literal. Thus the length and capacity of a slice literal are the maximum element index plus one. A slice literal has the form []T{x1, x2, … xn} and is shorthand for a slice operation applied to an array:

2 min read
Quiz results
I recently asked the following quiz question on this list, as well as on social media. What does the following code print? var hmm = [...]int{1, 2, 3, 12: 9, 8: 3} fmt.Println(len(hmm)) On social media, I provided the following options: 5 7 13 Doesn’t compile And now the results are in! I got a total of 428 responses across LinkedIn, Twitter, and Mastodon: The good news is: The majority are right!

1 min read
Special considerations for array literals
It’s Monday again. That means I’ll be live-coding again! I hope you can join me. Composite literals … The length of an array literal is the length specified in the literal type. If fewer elements than the length are provided in the literal, the missing elements are set to the zero value for the array element type. It is an error to provide elements with index values outside the index range of the array.