Refresher on methods

In yesterday’s email, I failed to include the example included in the spec, which doesn’t make sense to include otherwise. I’ve updated the web version of the email in case you’re super curious to see what I left out.We’ve already covered these details, but they’re logically ment … | Continue reading


@boldlygo.tech | 1 year ago

Special case: Multi-value arguments to functions

You may recall that when we started the section on function calls, we were told about a “special case”… well here it is!Calls …As a special case, if the return values of a function or method g are equal in number and individually assignable to the parameters of another function o … | Continue reading


@boldlygo.tech | 1 year ago

nil functions

Calls …Calling a nil function value causes a run-time panic.So, calling a nil function causes a panic. Sensible enough. But when would you ever run across a nil function?Let’s look at some examples.This is probably the most obvious example, and perhaps one that popped to your min … | Continue reading


@boldlygo.tech | 1 year ago

Evaluation of function parameters

Calls If f denotes a generic function, it must be instantiated before it can be called or used as a function value.We’ve seen this rule applied to methods and other types. It should be standard by now, so I won’t dwell on it.In a function call, the function value and arguments ar … | Continue reading


@boldlygo.tech | 1 year ago

Test-driven development: Love it or hate it

Denis Čahuk and Adrian Stanek have invited me to join them in their livestream today to discuss Test-Driven Development. I hope you’ll be able to join in on the conversation! For some it’s a bane they’d rather not hear about at work. For other it’s a core tool that they force the … | Continue reading


@boldlygo.tech | 1 year ago

The type of a function call expression

Calls … The type of the expression is the result type of F. A method invocation is similar but the method itself is specified as a selector upon a value of the receiver type for the method. math.Atan2(x, y) // function call var pt *Point pt.Scale(3.5) // method call with receiver … | Continue reading


@boldlygo.tech | 1 year ago

Calls

Calling all gophers!It’s time to talk about… Calls!Calls Given an expression f with a core type F of function type,f(a1, a2, … an) calls f with arguments a1, a2, … an.This basic syntax is common to many languages, so should not feel at all strange if you have any programming expe … | Continue reading


@boldlygo.tech | 1 year ago

Type assertion values

By now you’ve guessed there was no live stream today. Illess has been hitting my family hard. I’ll try to pick it up again after the new year.Type assertions …If the type assertion holds, the value of the expression is the value stored in x and its type is T. If the type assertio … | Continue reading


@boldlygo.tech | 1 year ago

Type assertions of interface types

Type assertions … If T is an interface type, x.(T) asserts that the dynamic type of x implements the interface T.This simple sentence has some pretty profound implications.Let’s start with a simple example:type Fooer interface { Foo() } type thing int func (thing) Foo() {} var x … | Continue reading


@boldlygo.tech | 1 year ago

Type assertions of non-interface types

Yesterday we started on type assertions. Today we’ll look at some of the specific details, as they relate to type assertions to non-interface types. Tomorrow we’ll look at interface types.Type assertions …More precisely, if T is not an interface type, x.(T) asserts that the dynam … | Continue reading


@boldlygo.tech | 1 year ago

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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year ago

Range of slice expressions

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


@boldlygo.tech | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year 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 | 1 year ago