84 cards across 4 sections
go build
go test
go fmt
go vet
1.27
encoding/json/v2
gofmt
1.18
runtime/pprof
simd
simd/archsimd
1.27.1
package name
main
import
var x int
0
false
""
nil
:=
const
const ( ... )
iota
type Point struct { X, Y int }
==
&x
*p
func (p *Point) Move(dx, dy int)
type Celsius float64
type Alias = float64
[3]int
[]int
append
s = append(s, x)
copy(dst, src)
s[low:high:max]
map[K]V
v, ok := m[k]
V
delete(m, k)
maps.Equal
maps
len
go f()
f
make(chan int)
make(chan int, 3)
select
default
wg.Add(n)
wg.Done()
wg.Wait()
mu.Lock()
mu.Unlock()
go run -race
go test -race
context.Context
ctx
context.WithCancel
context.WithTimeout
ctx.Done()
error
Error() string
(T, error)
fmt.Errorf("...: %w", err)
errors.Is
errors.As
panic
recover
defer f()
implements
interface{}
any
v, ok := x.(T)
switch x.(type)
x
is-a
io.ReadWriter
io.Reader
io.Writer
func Map[T, U any](s []T, f func(T) U) []U
comparable
~int | ~float64
func TestXxx(t *testing.T)
_test.go
t.Error
t.Fatal
t.Run(name, func(t *testing.T) {...})
func BenchmarkXxx(b *testing.B)
b.N
go test -bench=.
Printf
goimports
go mod init
go.mod
go.sum
go work init
staticcheck
golang.org/x/tools
fmt.Println
String() string
%v
%s
json:"name,omitempty"
json.Marshal
Unmarshal
http.HandleFunc
http.ListenAndServe
http.Client
context
Read
Write
time.Now
time.Duration
time.After
os.Open
os.ReadFile
defer f.Close()
slices
1.21
slices.Sort
slices.Contains
maps.Keys
go test -race ./...
fmt.Errorf
%w
if err != nil { return fmt.Errorf("load config: %w", err)}
if errors.Is(err, os.ErrNotExist) { // handle missing file}
sync.Mutex
var mu sync.Mutexmu.Lock()counter++mu.Unlock()
f, err := os.Open(path)if err != nil { return err}defer f.Close()
req, _ := http.NewRequestWithContext( ctx, "GET", url, nil)
safe := shared[0:3:3]safe = append(safe, 99) // no aliasing
+
strings.Builder
var b strings.Builderfor _, w := range words { b.WriteString(w)}result := b.String()
sync.Once
var once sync.Onceonce.Do(func() { client = newClient() })
jobs := make(chan Task, 100)for i := 0; i < 5; i++ { go worker(jobs)}
atomic.Int64
var hits atomic.Int64hits.Add(1)current := hits.Load()
constraints.Ordered
func Max[T cmp.Ordered](a, b T) T { if a > b { return a } return b}
type Logger struct{ *log.Logger }type Service struct{ Logger }
//go:embed
embed.FS
//go:embed templates/*.htmlvar templates embed.FS
t.Run
go test -run
for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { got := Add(tc.a, tc.b) if got != tc.want { t.Fail() } })}
err
1.22
for
go
go 1.22
go version -m
m[k] = v
make(map[K]V)
s[1:3]
s
copy
errors.Is(err, ErrSentinel)
if v, err := f(); err != nil
=
go vet -shadow
stop
init()
go vet ./...
gofmt -l .