Creează un cont pentru a te abona la acest blog și a-i urmări articolele pe pagina Lectură.
-
On Friday, I shared a short code snippet, and asked how it could be improved.
-
Today I want to share a bit of code I found in the wild, and challenge you to improve it.
-
Overview … Programs that use Contexts should follow these rules to keep interfaces consistent across packages and enable static analysis tools to check context propagation: Do not store Contexts inside a struct type; instead, pass a Context explicitly to…
-
We’ve seen that we can cancel contexts in a few ways–explicitly, or via timeouts.
-
As already mentioned, the context.Context type serves two purposes: It manages cancelation signals, and it allows passing request-scoped data.
-
Monday we looked at a very high-level view of what problems the context package is meant to solve.
-
Hey!
-
On Monday I talked about error structs.
-
The standard library gives us only very basic error capabilities.
-
Yesterday, Shay Nehmad and I, and close to 20 other people, recorded the 100th episode of the Cup o’ Go podcast.
-
Last week I talked about how to create your own errors.
-
Go 1.24 is released!
-
Yesterday I answered a reader question that included some often confused terminology.
-
Just over a year ago I started this (mostly) daily mailing list, with the goal of going through the entire Go spec, to make it easier for you (and me!)
-
This is it!
-
Package unsafe … The function String returns a string value whose underlying bytes start at ptr and whose length is len.
-
Package unsafe … The function Slice returns a slice whose underlying array starts at ptr and whose length and capacity are len.
-
I mentioned a few days ago that pointer arithmetic is possible through the unsafe package.
-
You’ll likely remember that certain built-in functions can sometimes evaluate to constants, rather than variables.
-
Package unsafe … Computer architectures may require memory addresses to be aligned; that is, for addresses of a variable to be a multiple of a factor, the variable’s type’s alignment.
-
Package unsafe … The function Offsetof takes a (possibly parenthesized) selector s.f, denoting a field f of the struct denoted by s or *s, and returns the field offset in bytes relative to the struct’s address.
-
Package unsafe … The functions Alignof and Sizeof take an expression x of any type and return the alignment or size, respectively, of a hypothetical variable v as if v was declared via var v = x.
-
Today we’re venturing into dangerous territory… the unsafe package!
-
Run-time panics Execution errors such as attempting to index an array out of bounds trigger a run-time panic equivalent to a call of the built-in function panic with a value of the implementation-defined interface type runtime.Error.
-
Today we’re looking at errors, and the built-in error interface.
-
Program execution A complete program is created by linking a single, unimported package called the main package with all the packages it imports, transitively.
-
I’ve been on an unannounced, unplanned, month-long hiatus, what with moving my family across the globe.
-
I wasn’t exactly planning to take last week off from the daily emails, but with Thanksgiving preparations, and still living out of a suitcase, it just happened that way.
-
We’ve been looking at the order of package variable initialization.
-
We’re nearing the end of the discussion on package initialization order.
-
Today’s section of the spec is a bit dense and technical.
-
Package initialization … The declaration order of variables declared in multiple files is determined by the order in which the files are presented to the compiler: Variables declared in the first file are declared before any of the variables declared in t…
-
Thank you to everyone who responded to yesterday’s pop quiz!
-
It’s time for a pop quiz.
-
I’m sorry for missing a couple days.
-
Today we have something a bit different.
-
Yesterday I promised to teach you the one dirty trick they don’t want you to know about, to get around Go’s restriction on circular imports.
-
First off, the spec provides an example of how to reference a symbol in an imported package, using different import alias options.
-
Today we’re looking at one of the more essoteric parts of the spec.
-
Newcomers to Go often try to use relative imports, and then are usually bitten by random weird problems.
-
We’re continuing today our discussion of imports.
-
Today we have a very important topic… Import declarations An import declaration states that the source file containing the declaration depends on functionality of the imported package (§Program initialization and execution) and enables access to exported…
-
I’m back!
-
A quick note to say that I’m taking next week off, for a move.
-
Handling panics … The return value of recover is nil when the goroutine is not panicking or recover was not called directly by a deferred function.
-
Yesterday we saw how panic plays with deferred functions, in terms of order of execution.
-
Handling panics … While executing a function F, an explicit call to panic or a run-time panic terminates the execution of F.
-
We’re ready for the section of the Go spec that talks about panic and recover, Go’s rough analogs to throw and catch.
-
Today’s topic: Allocation!
-
I always try to add my own commentary, examples, or other explanation in these emails.