← Înapoi la Urmăritori

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 200
  1. On Friday, I shared a short code snippet, and asked how it could be improved.

  2. Today I want to share a bit of code I found in the wild, and challenge you to improve it.

  3. Context rules

    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…

  4. Cancelation causes

    We’ve seen that we can cancel contexts in a few ways–explicitly, or via timeouts.

  5. Context cancelation

    As already mentioned, the context.Context type serves two purposes: It manages cancelation signals, and it allows passing request-scoped data.

  6. Context plumbing

    Monday we looked at a very high-level view of what problems the context package is meant to solve.

  7. context

    Hey!

  8. Error interfaces

    On Monday I talked about error structs.

  9. Error structs

    The standard library gives us only very basic error capabilities.

  10. Yesterday, Shay Nehmad and I, and close to 20 other people, recorded the 100th episode of the Cup o’ Go podcast.

  11. Constant errors

    Last week I talked about how to create your own errors.

  12. Go 1.24.0 is here!

    Go 1.24 is released!

  13. Type casting in Go

    Yesterday I answered a reader question that included some often confused terminology.

  14. Creating errors

    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!)

  15. This is it!

  16. Package unsafe … The function String returns a string value whose underlying bytes start at ptr and whose length is len.

  17. unsafe.Slice

    Package unsafe … The function Slice returns a slice whose underlying array starts at ptr and whose length and capacity are len.

  18. Pointer Arithmetic

    I mentioned a few days ago that pointer arithmetic is possible through the unsafe package.

  19. You’ll likely remember that certain built-in functions can sometimes evaluate to constants, rather than variables.

  20. Variable Alignment

    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.

  21. Offsetof

    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.

  22. 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.

  23. Package unsafe

    Today we’re venturing into dangerous territory… the unsafe package!

  24. Run-time panics

    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.

  25. Errors

    Today we’re looking at errors, and the built-in error interface.

  26. Program execution

    Program execution A complete program is created by linking a single, unimported package called the main package with all the packages it imports, transitively.

  27. Happy New Year!

    I’ve been on an unannounced, unplanned, month-long hiatus, what with moving my family across the globe.

  28. 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.

  29. init functions

    We’ve been looking at the order of package variable initialization.

  30. We’re nearing the end of the discussion on package initialization order.

  31. Today’s section of the spec is a bit dense and technical.

  32. 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…

  33. Thank you to everyone who responded to yesterday’s pop quiz!

  34. Pop quiz

    It’s time for a pop quiz.

  35. Zero values

    I’m sorry for missing a couple days.

  36. An example package

    Today we have something a bit different.

  37. 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.

  38. Import cycles

    First off, the spec provides an example of how to reference a symbol in an imported package, using different import alias options.

  39. Valid import paths

    Today we’re looking at one of the more essoteric parts of the spec.

  40. Relative imports

    Newcomers to Go often try to use relative imports, and then are usually bitten by random weird problems.

  41. We’re continuing today our discussion of imports.

  42. Import declarations

    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…

  43. Packages

    I’m back!

  44. Bootstrapping

    A quick note to say that I’m taking next week off, for a move.

  45. Recover values

    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.

  46. Order of recovery

    Yesterday we saw how panic plays with deferred functions, in terms of order of execution.

  47. Handling panics … While executing a function F, an explicit call to panic or a run-time panic terminates the execution of F.

  48. Don't panic!

    We’re ready for the section of the Go spec that talks about panic and recover, Go’s rough analogs to throw and catch.

  49. Allocation

    Today’s topic: Allocation!

  50. Min and max

    I always try to add my own commentary, examples, or other explanation in these emails.