Clarity
0値のフィールドを省略する
ことで指定されている
オプションが目立つ
// Bad
ldb := leveldb.Open("/my/table", &db.Options{
BlockSize: 1<<16,
ErrorIfDBExists: true,
// These fields all have their zero values.
BlockRestartInterval: 0,
Comparer: nil,
})
Simplicity
genericsは使わないで済む
場合は使わない
// Bad
func ReadFour[T io.Reader](r T) ([]byte, error)
// Good
func ReadFour(r io.Reader) ([]byte, error)
The original code was shown by GopherCon 2021: Robert Griesemer & Ian Lance Taylor - Generics!
https://www.youtube.com/watch?v=Pa_e9EeCdy8
Slide 26
Slide 26 text
Simplicity
%qを使う
// Bad
fmt.Printf("value \"%s\" looks like English text",
someText)
fmt.Printf("value '%s' looks like English text",
someText)
// Good
fmt.Printf("value %q looks like English text",
someText)