Jaana Dogan
rakyll.org · Personal blog · on HN since 2014
Jaana Dogan, a software engineer, writes about the Go language, including generics, the scheduler, package style, and profiling.
What HN saysHN links it for Go explanations, such as its generics workaround and its account of how the work-stealing scheduler works.
40HN people shared it
9linked it in comments
38stories submitted
668story points
4 years agolast shared
2014people per year2026
Most-shared posts
- 1Generics facilitators in Go5 people · 196 points · first shared 2021 · 130 comments on HN
- 2Style guideline for Go packages5 people · 6 points · first shared 2017 · discussion on HN
- 3Go for Cloud4 people · 13 points · first shared 2020 · discussion on HN
- 4The Go type system for newcomers4 people · 9 points · first shared 2017 · discussion on HN
- 5Shardz3 people · 66 points · first shared 2021 · 1 comments on HN
- 6Inlined Defers3 people · 5 points · first shared 2020 · discussion on HN
- 7Go's work-stealing scheduler2 people · 200 points · first shared 2017 · 69 comments on HN
- 8The future of latency profiling in Go2 people · 148 points · first shared 2017 · 14 comments on HN
- 9Interface pollution in Go2 people · 4 points · first shared 2018 · discussion on HN
- 10Inlined Defers in Go2 people · 2 points · first shared 2020 · discussion on HN
- 11Custom pprof profiles2 people · 2 points · first shared 2017 · discussion on HN
- 12Analysis of Golang 1.8 Contributions2 people · 1 points · first shared 2017 · discussion on HN
- 13Golang tooling essentials: useful flags and options1 people · 4 points · first shared 2017 · discussion on HN
- 14Spanner's High Availability Writes1 people · 3 points · first shared 2021 · discussion on HN
- 15Debugging code generation in Go1 people · 2 points · first shared 2017 · discussion on HN
What HN people wrote when they linked it
thegeekpirate · 2022-07-08
You can certainly use generic parameters in methods—the [T any] just has to be on SomeNonGenericType, even if it's not used inside the type itself https://rakyll.org/generics-facilititators
robertsdionne · 2022-04-20
via https://rakyll.org/generics-facilititators/
Example:
https://go.dev/play/p/as3rT4fB3cn
// Invocation:
strings := []string
{"1", "2", "3"}
ints, err := Mapper[string, int](strings).MapErr(strconv.Atoi)
strings = Mapper[string, string](strings).Map(func(s string) string
{
return s + "_suffix"
})
// Definition:
type Mapper[T, U any] []T
func (ts Mapper[T, U]) Map(f func(T) U) (us []U)
{
us, _ = ts.MapErr(func(t T) (u U, err error)
{
u = f(t)
return
})
return
}
func (ts Mapper[T, U]) MapErr(f func(T) (U, error)) (us []U, err error)
{
us = make([]U, 0, len(ts))
for _, t := range ts
{
var u U
u, err = f(t)
if err != nil
{
return
}
us = append(us, u)
}
return
}
noah_buddy · 2021-12-22
I believe they're talking about the semi-duck typing used in go for interfaces but I'm not certain. Interfaces are implicitly implemented with a runtime check determining whether a type x assigned to interface y is valid.This is why you'll often see an empty declaration in packages for structs intended to implement an interface like so:
var _ y = x
{} // syntax might be slightly wrong
After writing this, I found the linked article in the OP link to what the author meant.
https://rakyll.org/typesystem/
There's really a bunch of small things that are different about golang that individually you can find elsewhere but are on the whole unique.
hactually · 2020-05-13
A good presentation did the rounds a while ago[0] that does a deeper dive but the main things for us are the performance, smaller binaries and the improvements in tooling.
The one thing I wish they added though? `go new` and have it initialise a new project structure that stopped tiny package syndrome and bizarre Makefiles in repos! [1]
[0] https://docs.google.com/presentation/d/1veyF0y6Ynr6AFzd9gXi4foaURlgbMx…
[1] https://rakyll.org/style-packages/
echlebek · 2018-04-30
The way all of this works is nicely detailed here: https://rakyll.org/scheduler/
akavel · 2017-05-25
Haven't tried it personally, but based on a recent article shared at r/golang (https://rakyll.org/coredumps/, via https://www.reddit.com/r/golang/comments/6cvtd6/debugging_go_core_dump… delve seems to show the contents of an .s file allright.
dbaupp · 2017-01-19
Go does accept pull requests, just not GitHub ones: https://golang.org/doc/contribute.html#Code_review
(I don't disagree with the premise though, Go does seem to be less community-driven than Rust; e.g. Rust has 3 mozilla employees in the top 10 contributors for the most recent release[0], where as Go has 9 Googlers in its top 10[1].)
[0]: https://github.com/rust-lang/rust/graphs/contributors?from=2016-09-29&…
[1]: https://rakyll.org/go18cls/
burntsushi · 2018-01-01
Cross posting my comment from the crusty news aggregator site:
I liked this blog post and agree with most of it. But I think its section on interfaces is a bit muddled. It links to this article[1] for more advice, and while the article sounds nice in principle from the perspective of someone publishing a library for others to use, I’ve found other techniques to be valuable as well.
One technique I’m particularly fond of is writing a package whose main goal is to provide an abstraction layer between a storage system (e.g., PostgreSQL) and one’s model of data. The utility of the package permits callers to access data without caring too much about the underlying details of the storage itself.
This on its own doesn’t require an interface. It makes sense to define a type that implements various routines that interact with the storage layer and be done with it. But something what’s really useful is to create an in-memory version using the exact same API with the same contracts. It’s useful to use the in-memory version not necessarily just in testing, but potentially also in command line debugging tools. In particular, it lets one debug or test other components of the system without necessarily depending on a running storage service. This doesn’t replace integration tests, of course, but it does permit unit testing in a more fine grained way.
The only real issue here is that you want everyone else that uses this storage system to be able to also use the in-memory implementation…
heavenlyhash · 2017-01-06
There's a problem lurking behind this "simple" model: the goroutine you park on that blocking IO operation can't be collected reliably itself.
I care about collecting goroutines, and would advocate that everyone should care about this. There's been a litany [1] of blogs about this recently, if anyone doesn't consider this self-evident. It's just systematically sane. Letting goroutines spin off into the distance with no supervision is extremely likely to represent either a resource leak, a missing error handle path, or an outright logic bug.
In a dream world, we might have Erlang-style supervisor trees so this can all be done with less boilerplate. It's almost even possible to do this as a library in go! ... except for this blocking IO problem, which throws a wrench in things: any supervisor of a goroutine that may be IO-blocked may itself be indefinitely stuck, and so on up-tree, making the concept unworkable.
---
[1] Some recent articles hammering the point of "collect your goroutines":
- https://dave.cheney.net/2016/12/22/never-start-a-goroutine-without-kno…
- https://rakyll.org/leakingctx/