Type assertions

Type assertions For an expression x of interface type, but not a type parameter, and a type T, the primary expression x.(T) asserts that x is not nil and that the value stored in x is of type T. The notation x.(T) is called a type assertion. For now, let’s look at some examples o … | Continue reading


@boldlygo.tech | 5 months ago

Half way there

No live stream today. I’m still feeling a bit under the weather. Hopefully next week we’ll be back on schedule.In January, I started this series on the Go spec, not having any idea if I'd have even 2 readers, or how long it would take to get through the whole spec. This week we p … | Continue reading


@boldlygo.tech | 5 months ago

Farewell, November

For those of you who aren’t regular watchers of my YouTube channel, I wanted to call your attention to the series I just wrapped up this month for “No-Effort November”. Other than the theme of low-production effort, and short videos, the only real theme is “Go topics”. But I’ve g … | Continue reading


@boldlygo.tech | 5 months ago

Full slice expressions

Full slice expressions The primary expression a[low : high : max] constructs a slice of the same type, and with the same length and elements as the simple slice expression a[low : high]. Additionally, it controls the resulting slice’s capacity by setting it to max - low. So I’ll … | Continue reading


@boldlygo.tech | 5 months ago

Slice expression result types

No live stream today. Next week I expect to be back at it! Forgive me for not sending an email Friday. I spent the day in bed. ️ But I’m back on my feet now! So up to now we’ve learned how to use slice expressions… but what is the type that results? Well, you can probably guess. … | Continue reading


@boldlygo.tech | 5 months ago

Range of slice expressions

Simple slice expressions … For arrays or strings, the indices are in range if 0 | Continue reading


@boldlygo.tech | 5 months ago

Quiz

Today’s quiz day. Tomorrow I’ll provide the answer as we continue with the section of the spec that explains today’s code. Consider the following program. What is its output? package main import "fmt" func main() { a := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} s := a[2:5] s2 := s[5:7 … | Continue reading


@boldlygo.tech | 5 months ago

Simple slice expression shortcuts

Simple slice expressions, which we started with yesterday, offer us two shortcuts: Simple slice expressions … For convenience, any of the indices may be omitted. A missing low index defaults to zero; a missing high index defaults to the length of the sliced operand: a[2:] // same … | Continue reading


@boldlygo.tech | 5 months ago

Slice expressions

Last week’s livestream turned out to be a bit of a disappointment, as some Docker problems prevented me from making any real progress. I’ve resolved that, so today I hope to hit the ground running with some Kubernetes deployments! I hope you can join me again today on my live str … | Continue reading


@boldlygo.tech | 5 months ago

Index expression special cases for maps

Today we’re finishing up our discussion of…Index expressions …So far, we’ve discussed what index expressions are, and specific rules as they apply to:arrays slices and strings maps type parameters Otherwise a[x] is illegal.But there are two more special cases to consider for maps … | Continue reading


@boldlygo.tech | 5 months ago

Index expressions for type parameters

Index expressions … For a of type parameter type P: So just a reminder what this means: We’re talking about index expressions for different data types. And we’re going through different interpretations of the expression a[x]. In this example, a is of a “type parameter” type, repr … | Continue reading


@boldlygo.tech | 5 months ago

Index expressions for maps

Index expressions …For a of map type M:x’s type must be assignable to the key type of M No surprise here. The key must be assignable to the key type. But notably, it needn’t be of an identical type, so long as it is assignable to the key type.m := map[string]int{ "foo": 3, "bar": … | Continue reading


@boldlygo.tech | 5 months ago

Index expressions for slices and strings

Index expressions … For a of slice type S: if x is out of range at run time, a run-time panic occurs a[x] is the slice element at index x and the type of a[x] is the element type of S This is essentially identical to the rules for arrays, except that there’s no possibility of a c … | Continue reading


@boldlygo.tech | 5 months ago

Index expressions for arrays

I hope you can join me again today on my live stream, when I’ll be continuing my series about deploying a simple Go app to Kubernetes.Last week we started with index expressions. Today we look at the additional rules that apply specifically to index expressions for arrays.Index e … | Continue reading


@boldlygo.tech | 5 months ago

Index expressions

Index expressions A primary expression of the forma[x] denotes the element of the array, pointer to array, slice, string or map a indexed by x. The value x is called the index or map key, respectively. The following rules apply:If a is neither a map nor a type parameter:Alright, … | Continue reading


@boldlygo.tech | 6 months ago

I'm looking for new clients

Could your project benefit from my expertise?I’ve had some availability open up in my schedule recently, so I’m announcing my new “Fractional Gopher” subscription service. I can help build your new features, pay down technical debt, audit your project’s code and architecture, or … | Continue reading


@boldlygo.tech | 6 months ago

Method values, part 2

Today we finish up the spec’s section on method values, with some very non-surprising bits:Method values …As with selectors, a reference to a non-interface method with a value receiver using a pointer will automatically dereference that pointer: pt.Mv is equivalent to (*pt).Mv.As … | Continue reading


@boldlygo.tech | 6 months ago

Resume advice for a first-time job seeker

Back in May, I published a video review of the resume of a seasoned Go developer. Recently, I was asked to review the resume of someone with no formal job experience, as well. So that’s what I’ve done in my latest video: Resume advice for a first-time job seeker.Whether you are a … | Continue reading


@boldlygo.tech | 6 months ago

Method values

A quick reminder: In today’s live stream, I’ll be deploying a Go app to Kubernetes! I hope you’ll join me!Today we continue the explanation of Method values. There’s nothing too surprising today. The spec mostly just confirms what should seem natural…Method values …As in the disc … | Continue reading


@boldlygo.tech | 6 months ago

Let's do Kubernetes

I’m taking a small detour today, to a topic that’s not strictly Go-related, but which I get asked about a lot: Docker and Kubernetes.Starting on Monday, in what is likely to become a 2- or 3-week series, I’m going to be deploying a small Go app I wrote, to Kubernetes on Google Cl … | Continue reading


@boldlygo.tech | 6 months ago

Resume advice for a first-time job seeker

I review the résumé/CV of a first-time job seeker, looking for a Go-related job. | Continue reading


@boldlygo.tech | 6 months ago

Method values

As I promised yesterday, today we’re looking at method values, a concept with some similarties to the previous concept of method expressions, but with a bit more utility. Method values If the expression x has static type T and M is in the method set of type T, x.M is called a met … | Continue reading


@boldlygo.tech | 6 months ago

Method expressions, conclusion

Today we’ll finish our discussoin of method expression from Monday and Tuesday.Method expressions …Function values derived from methods are called with function call syntax; the receiver is provided as the first argument to the call. That is, given f := T.Mv, f is invoked as f(t, … | Continue reading


@boldlygo.tech | 6 months ago

Method expressions, part 2

Today I’ll continue where I left off yesterday, talking about…Method expressions …Similarly, the expression(*T).Mp yields a function value representing Mp with signaturefunc(tp *T, f float32) float32 The key difference to notice between this example and yesterday’s is that the fi … | Continue reading


@boldlygo.tech | 6 months ago

Method expressions

There was no livestream today, as I was a bit under the weather. I intend to be back live streaming next Monday as usual Method expressions If M is in the method set of type T, T.M is a function that is callable as a regular function with the same arguments as M prefixed by an ad … | Continue reading


@boldlygo.tech | 6 months ago

Illegal selectors

We’ll cover the last 3 rules of selectors in one go today, since they’re all about illegal selectors. Selectors … In all other cases, x.f is illegal. Simple enough. The cases mentioned in rules 1-3 ar ethe only valid uses of x.f. All others are illegal. var x int x.chicken // ill … | Continue reading


@boldlygo.tech | 6 months ago

Third rule of selectors

Selectors … As an exception, if the type of x is a defined pointer type and (*x).f is a valid selector expression denoting a field (but not a method), x.f is shorthand for (*x).f. I find this wording to be confusing. That probably means some of you do, too. So here goes my best a … | Continue reading


@boldlygo.tech | 6 months ago

Don't mock slog

Are you excited to hit the ground running with Go 1.21’s new log/slog package? That means testing it, right? And testing means mocks, right? Not so fast! Don’t mock slog! In my latest video, I talk about the problems with mocking, and the super simple alternative you can use when … | Continue reading


@boldlygo.tech | 6 months ago