Assignment statements

Assignment statements An assignment replaces the current value stored in a variable with a new value specified by an expression. Assignments should be familiar to you. They’re pretty fundamental to almost all programming languages. But there are a few aspects to Go’s assignments … | Continue reading


@boldlygo.tech | 9 days ago

IncDec statements

IncDec statements The “++” and “–” statements increment or decrement their operands by the untyped constant 1. As with an assignment, the operand must be addressable or a map index expression. IncDecStmt = Expression ( "++" | "--" ) . Most commonly you’ll see ++ and -- used on a … | Continue reading


@boldlygo.tech | 10 days ago

Send statements

Send statements A send statement sends a value on a channel. The channel expression’s core type must be a channel, the channel direction must permit send operations, and the type of the value to be sent must be assignable to the channel’s element type. SendStmt = Channel "<-" Exp … | Continue reading


@boldlygo.tech | 11 days ago

Expression statements

No livestream today. I wasn’t feeling well enough. No live stream next week either, as I’ll be traveling. Expression statements With the exception of specific built-in functions, function and method calls and receive operations can appear in statement context. Such statements may … | Continue reading


@boldlygo.tech | 12 days ago

Labeled statements

Today we’ll talk about labeled statements, which we’ve just recently mentioned in the context of terminating statements. Labeled statements A labeled statement may be the target of a goto, break or continue statement. LabeledStmt = Label ":" Statement . Label = identifier . Error … | Continue reading


@boldlygo.tech | 15 days ago

Labeled statements

Today we’ll talk about labeled statements, which we’ve just recently mentioned in the context of terminating statements. Labeled statements A labeled statement may be the target of a goto, break or continue statement. LabeledStmt = Label ":" Statement . Label = identifier . Error … | Continue reading


@boldlygo.tech | 16 days ago

Empty statements

Empty statements The empty statement does nothing. EmptyStmt = . I don’t think there’s much to say here. I suppose we could spend some time debating if/when an empty statement exists in our code. How many empty statements in the following? Is it one? Zero? An infinite number? How … | Continue reading


@boldlygo.tech | 17 days ago

Terminating statements conclusion

So we’ve made it through the list of 8 types of terminating statements. We conclude this section with a couple additional comments: Terminating statements … All other statements are not terminating. A statement list ends in a terminating statement if the list is not empty and its … | Continue reading


@boldlygo.tech | 18 days ago

Terminating labeled statements

Today’s live stream is starting an hour later than usual. Join me at 16:00, CEST, for some live Go coding using TDD. Terminating statements … A labeled statement labeling a terminating statement. Labeled statement’s are not used a lot in Go. Terminating labeled statements even le … | Continue reading


@boldlygo.tech | 19 days ago

Terminating select statements

Terminating statements … A “select” statement in which: there are no “break” statements referring to the “select” statement, and the statement lists in each case, including the default if present, end in a terminating statement. This is quite similar to the “switch” case we looke … | Continue reading


@boldlygo.tech | 22 days ago

Terminating switch statements

Terminating statements … A “switch” statement in which: there are no “break” statements referring to the “switch” statement, there is a default case, and the statement lists in each case, including the default, end in a terminating statement, or a possibly labeled “fallthrough” s … | Continue reading


@boldlygo.tech | 23 days ago

Terminating for loops

Terminating statements … A “for” statement in which: there are no “break” statements referring to the “for” statement, and the loop condition is absent, and the “for” statement does not use a range clause. Put another way, a for statement is terminating if it either never ends (a … | Continue reading


@boldlygo.tech | 24 days ago

Terminating if statements

Last week we saw that a block that ends in a terminaging statement is itself a terminating statement. Today we expand a bit on that idea: Terminating statements … An “if” statement in which: the “else” branch is present, and both branches are terminating statements. In other word … | Continue reading


@boldlygo.tech | 25 days ago

Happy April Fool's Day

I’ll be streaming some live coding again, on this April Fool’s day. No joke. I hope you’ll join me. It’s April Fool’s day. And I also recently learned of #AprilCools – the idea of doing something off-topic, but serious, rather than cringey on April first. So this year, I, eh… ext … | Continue reading


@boldlygo.tech | 26 days ago

Terminating blocks

Terminating statements … A block in which the statement list ends in a terminating statement. What exactly does this mean? It means that if you have an (explicit) code block that ends in a terminating statement, the block itself is considered a terminating statement. Confused? Ho … | Continue reading


@boldlygo.tech | 29 days ago

Don't panic!

Later today, at 15:00 UTC, I’ll be joining Denis Čahuk and Adrian Stanek on their regular Livestream, Our Tech Journey, to talk about TDD, Go, and do some live coding. Join us! The second in our list of terminating statements is… panic! Terminating statements … A call to the buil … | Continue reading


@boldlygo.tech | 1 month ago

Terminating statements

Terminating statements A terminating statement interrupts the regular flow of control in a block. The following statements are terminating: A “return” or “goto” statement. The return statement should be familiar to virtually everyone. And the fact that it interrupts the regular f … | Continue reading


@boldlygo.tech | 1 month ago

Statements

At long last, we have completed the section of the spec on expressions… and now we move on to: Statements Statements control execution. Statement = Declaration | LabeledStmt | SimpleStmt | GoStmt | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt | FallthroughStmt | Block | IfStm … | Continue reading


@boldlygo.tech | 1 month ago

Order of evaluation and floating point numbers

Today I’ll be live streaming again! This time, picking up where we left off last week, and adding another feature to my new Go code rewriter and simplifier. Join me! Order of Evaluation … Floating-point operations within a single expression are evaluated according to the associat … | Continue reading


@boldlygo.tech | 1 month ago

Initialization dependencies

Here’s a thing you’ve likely never thought about: What if you have a compound assignment statement, where one of the variables depends on the other in the same statement. That’s what we’re looking at today. Order of Evaluation … At package level, initialization dependencies overr … | Continue reading


@boldlygo.tech | 1 month ago

Unordered evaluation

Yesterday’s spec quote included a sentence we breezed over. Today we’re going to dig in a bit more: Order of Evaluation … the order of those events compared to the evaluation and indexing of x and the evaluation of y and z is not specified, except as required lexically. What exac … | Continue reading


@boldlygo.tech | 1 month ago

Order of Evaluation

Let’s talk about… the order of evaluation! You might think you have a strong grasp on this concept, but many languages have their own nuanced take on evaluation order in some cases. And then JavaScript has “hoisting”, which kinda spits in the face of order of evaluation. Before w … | Continue reading


@boldlygo.tech | 1 month ago

Constant expressions, part III

Did you miss yesterday’s Ask-me-anything session? You probably did. I had about 10-15 people there. But even with a small group, we had a ton of great questions! The Q&A session lasted about an hour, and covered topics such as book recommendations for going deeper into Go, what p … | Continue reading


@boldlygo.tech | 1 month ago

Constant expressions, continued

Today I’ll be answering your questions on my weekly live stream. Have a question about Go? About CI/CD? About my favorite pizza toppings? Join me! Or submit your question early and catch the replay, if you can’t join live. Today we continue the section on Constant expressions, wi … | Continue reading


@boldlygo.tech | 1 month ago

Constant expressions

We made it through all the conversion rules! Let’s change gear and talk about… Constant expressions Constant expressions may contain only constant operands and are evaluated at compile time. Or framed differently: Any expression that contains non-constant operands, is not a const … | Continue reading


@boldlygo.tech | 1 month ago

Conversions from slice to array or array pointer

Conversions to and from a string type …Converting a slice to an array yields an array containing the elements of the underlying array of the slice. Similarly, converting a slice to an array pointer yields a pointer to the underlying array of the slice. In both cases, if the lengt … | Continue reading


@boldlygo.tech | 1 month ago

Converting integers to strings

Sorry I missed yesterday. The family road trip ended later than expected, and I was too shot to write anything. Conversions to and from a string type … Finally, for historical reasons, an integer value may be converted to a string type. This form of conversion yields a string con … | Continue reading


@boldlygo.tech | 1 month ago

Converting slices to byte or rune slices

No livestream today, as I’m traveling with my family. See you next week! Conversions to and from a string type … Converting a value of a string type to a slice of bytes type yields a non-nil slice whose successive elements are the bytes of the string. []byte("hellø") // []byte{&# … | Continue reading


@boldlygo.tech | 1 month ago

Converting rune slices to strings

Yesterday we started through the list of rules and special cases for converting to and from string types. Let’s continue… Conversions to and from a string type … Converting a slice of runes to a string type yields a string that is the concatenation of the individual rune values c … | Continue reading


@boldlygo.tech | 1 month ago

Conversions to and from a string type

Before I dive in to today’s spec discussion… are you enjoying this series? If so, would you do me a favor and help spread the word? Can you share a link to this message with a fellow Gopher, or on your work chat? Conversion to and from string types is a minefield of special cases … | Continue reading


@boldlygo.tech | 1 month ago

Conversions between numeric types

So we’ve gone through the high-level conversion stuff… now we dive into some particulars. Today, numeric conversions.Conversions between numeric types For the conversion of non-constant numeric values, the following rules apply:When converting between integer types, if the value … | Continue reading


@boldlygo.tech | 1 month ago

Type Conversion & struct tgs

We’ve already mentioned that struct tags are ignored when doing conversion between struct types. Now we see where that’s defined, along with an example:Conversions …Struct tags are ignored when comparing struct types for identity for the purpose of conversion:type Person struct { … | Continue reading


@boldlygo.tech | 1 month ago

Conversion of type parameters

Today I’ll be live-streaming again, doing TDD on an open-source project. I hope you can join! Conversions … Additionally, if T or x’s type V are type parameters, x can also be converted to type T if one of the following conditions applies: Both V and T are type parameters and a v … | Continue reading


@boldlygo.tech | 1 month ago

Non-constant conversions, part 2

Today we’ll finish the list of non-constant conversion rules that don’t relate to type parameters. Conversions … x’s type and T are both integer or floating point types. x’s type and T are both complex types. x is an integer or a slice of bytes or runes and T is a string type. x … | Continue reading


@boldlygo.tech | 1 month ago

Non-constant conversions

Yesterday we looked at conversions of constants. Let’s now consider the more common conversion scenarios of variables and other non-constant expressions. Conversions … A non-constant value x can be converted to type T in any of these cases: x is assignable to T. ignoring struct t … | Continue reading


@boldlygo.tech | 1 month ago

Conversion of constants

In case you missed it… It has come to my attention that Monday’s livestream went to the wrong stream on YouTube! This means if you followed the link I shared with you on Monday, you likely sat there waiting for 2 hours, only to be disappointed by a lack of live programming. Alas … | Continue reading


@boldlygo.tech | 1 month ago

Ambiguous conversion expressions

There aren’t many places where Go syntax is ambiguous, but here’s one:Conversions …If the type starts with the operator * or <-, or if the type starts with the keyword func and has no result list, it must be parenthesized when necessary to avoid ambiguity:*Point(p) // same as *(P … | Continue reading


@boldlygo.tech | 2 months ago

Conversions

On todays’s livestream, we’ll be Pair Programming on a real project. I hope to see you there! Conversions A conversion changes the type of an expression to the type specified by the conversion. A conversion may appear literally in the source, or it may be implied by the context i … | Continue reading


@boldlygo.tech | 2 months ago

Receive operator

Channels are deceptively simple. They seem a bit magical. They feel like they do something. They feel like they send data around your system. But they really don’t. They’re just data types. They’re probably best thought of like Go’s array or slice type, with the limitation that y … | Continue reading


@boldlygo.tech | 2 months ago

Live pair programming on a real project

Mark your calendar! If you’ve ever been curious about pair programming, and want to see it in action on a real project, not just a coding exercise, you’ll want to join Monday’s livestream. I’ll be doing some live Pair Programming with Denis Čahuk and Adrian Stanek. Denis and Adri … | Continue reading


@boldlygo.tech | 2 months ago

Address operators

Let’s talk about addresses.Address operators For an operand x of type T, the address operation &x generates a pointer of type *T to x. The operand must be addressable, that is, either a variable, pointer indirection, or slice indexing operation; or a field selector of an addressa … | Continue reading


@boldlygo.tech | 2 months ago

Logical Operators

Logical operators Logical operators apply to boolean values and yield a result of the same type as the operands. The left operand is evaluated, and then the right if the condition requires it. && conditional AND p && q is "if p then q else false" || conditional OR p || q is "if p … | Continue reading


@boldlygo.tech | 2 months ago

Introducing Go 1.22!

Join me in less than an hour, when I’ll be live streaming again! I’ll be continuing to add SQLite support to Kivik, using Test-Driven Development.Go 1.22 was released on February 7. So I’m a bit behind on talking about the changes introduced to the spec. But better late than neve … | Continue reading


@boldlygo.tech | 2 months ago

Comparison operators, conclusion

Comparison operators …Slice, map, and function types are not comparable. However, as a special case, a slice, map, or function value may be compared to the predeclared identifier nil. Comparison of pointer, channel, and interface values to nil is also allowed and follows from the … | Continue reading


@boldlygo.tech | 2 months ago

Comparison operators, part IV

Comparison operators …Struct types are comparable if all their field types are comparable. Two struct values are equal if their corresponding non-blank field values are equal. The fields are compared in source order, and comparison stops as soon as two field values differ (or all … | Continue reading


@boldlygo.tech | 2 months ago

Comparison operators, part III

Today we continue through the list of data types and how comparison and ordering works on each.Comparison operators …Channel types are comparable. Two channel values are equal if they were created by the same call to make or if both have value nil. Notice that channel comparison … | Continue reading


@boldlygo.tech | 2 months ago

Comparison operators, continued

Yesterday we started on comparison operators. Today we’ll continue, but there are a lot of types to cover, so I’ll break this down into a two or three parts, to keep each day’s email easily digestible.Recall that we had just been introduced to the concepts of ordered and comparab … | Continue reading


@boldlygo.tech | 2 months ago

Comparison operators

I’ll be livestreaming again today! I hope you can join me as I continue where I left off last week, adding some new features to my open-source library, Kivik!Let’s talk about a mundane detail… that actually has some interesting nuances: Comparisons!Comparison operators Comparison … | Continue reading


@boldlygo.tech | 2 months ago