summaryrefslogtreecommitdiff
path: root/daily/19-May-2025.md
blob: aa9ab6b18f5c5ea6ff07d35ffefcc8593c8fc322 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# Another note on Go
`image/color` package features the Color interface defining a Color as just a type that has a method `RGBA() (r, g, b, a uint32)`. It has a struct `RGBA` defining this method. So for example to define green we can say: `color.RGBA{0x00, 0xFF, 0x00, 0xFF}` R G B A respectively.

Packaging doing stuff with networking are grouped under `net`, e.g `net/http`

Using `io.Copy` we can copy output from a reader to a writer. This way we can for example copy a HTTP response directly to stdout instead of buffering the entire output first.

`strings.HasPrefix` exists

To get a time delta we can use `time.Since` which returns a `time.Time`. We can just call for example `Seconds()` on that to get the elapsed seconds.

Goroutines run concurrently and communicate over channels, they are started with the `go` keyword. Sending or receiving on a channel block the goroutine.