Golang log to file, stdout, and syslog with the standard log package
Golang log to file with os.OpenFile and log.SetOutput; golang log to file and stdout using io.MultiWriter; golang log syslog on Linux; go import log and golang log example; concurrency-safe default log.Logger.
Go functions with multiple types: `any`, type switches, and generics
Golang function parameter multiple types: use any/interface{} with a type switch, golang function types with type parameters (generics), go function types and golang func type constraints, plus golang pass type as …
Call a Function From Another Package or File in Go
Call Go code from another file or another package: what to import, when you do not need an import, capital letters for public functions, and how to fix typical errors.
go list installed packages: list Go packages, modules, and install paths
go list command for std, ./..., and all; go list -m all for modules; where Go stores packages (GOMODCACHE, GOROOT, GOPATH/bin); list go packages and binaries from go install without mistaking modules for a global package …
Golang Anonymous Function Explained with Examples
Learn anonymous functions in Go: function literals, immediate calls, parameters and return values, variables, callbacks, closures, goroutines, and common mistakes like loop capture.
Golang os exit, defer, and why deferred functions are not run
Golang os exit defer: os.Exit golang behavior matches pkg.go.dev os Exit — program terminates immediately and deferred functions are not run; patterns to run cleanup before exit, go os.exit deferred functions official …
Golang os.Stat: file metadata, FileInfo, and os.ErrNotExist
Golang os.stat and golang os stat: os.Stat returns fs.FileInfo (name, size, mode, mod time, IsDir); *File.Stat; errors.Is(err, os.ErrNotExist); os.Lstat vs Stat; PathError. Related os package file I/O.
Golang json omitempty: meaning, zero values, and nested structs
Golang json omitempty and omitempty meaning in encoding/json; golang omitempty with strings, numbers, pointers; why omitempty has no effect omitting nested struct value fields; use pointers for optional objects; go json …
Golang reverse range and iterate a slice backwards
Golang reverse range and golang range reverse with a backward index loop; golang range backwards using forward range and remapped index; golang iterate over slice and golang iterate slice backwards; golang reverse slice …
Golang split string and assign to variables: strings.Split, Fields, and Cut
Golang split string and golang string split with strings.Split and strings.Fields; strings split golang and go split string; golang split string into two variables with strings.Cut or slice indexing; net.SplitHostPort …
Golang set cookie and golang http cookie with net/http
Golang set cookie with http.SetCookie and http.Cookie, golang http cookie headers, golang cookies and cookie golang reads via Request.Cookie, Path Domain MaxAge Expires SameSite Secure HttpOnly, order before Write, curl …
Golang os package: Open, Create, WriteFile, and *os.File
Golang os package for files: golang os open and OpenFile, os create golang with os.Create, os writefile golang with os.WriteFile, *os.File reads and append, Stat and errors.Is(os.ErrNotExist), Remove.
Golang iterate over array: range and for loops with len
Golang iterate over array and golang array loop with for range; golang for loop array and golang loop through array using len; go iterate over array and iterate over array golang with index or values only.
Golang for loop and `for range`: slices, maps, structs, interfaces, channels
Golang for loop and go for loop guide: for loop in golang syntax, golang for cycle with three-part and while-style loops, for range over slices, maps, strings, golang iterate struct fields with reflect, golang iterate …
Convert Go []byte to string (Casting, Builder, Buffer, strconv)
Convert go bytes to string with string(b), fmt.Sprintf, strings.Builder or bytes.Buffer, strconv for numbers, and know when copying happens for UTF-8 text and binary data.
Use Go as a Redis Client (go-redis, Ping, Get, Set, Hashes)
Connect a Go program to Redis with github.com/redis/go-redis/v9, Ping with context, Set and Get strings, and store hashes; run Redis locally and match password and DB settings.
Get Current Time in Milliseconds in Go (UnixMilli and Alternatives)
Convert time.Time to Unix milliseconds with UnixMilli, derive ms from UnixNano, or use Duration.Milliseconds after Sub; know int64 range limits from the time package docs.
Golang io.ReadCloser: Reader+Closer, NopCloser, and read to string
io.ReadCloser golang and golang readcloser: embed io.Reader and io.Closer, io.NopCloser / nopcloser for Readers without real Close, golang io reader examples, and io.readcloser to string with io.ReadAll plus defer Close.
Golang gRPC tutorial: server, client, and Protocol Buffers example
Golang grpc example and grpc golang tutorial: proto3 service, golang grpc server and grpc server golang with Register and Serve, go grpc client and go grpc example with grpc.NewClient and transport credentials, grpc go …
Golang integer types: int, int32, int64, uint, and sizes
Golang int and go int types, golang int types and sizes, golang int vs int32, uint and sized integers, byte and rune aliases, and how golang data types size depends on int versus int8–int64.
Golang int to int64 and int64 to int conversion
Golang int to int64 and golang convert int to int64 with T conversions; golang int64 to int and int64 to int golang narrowing; go int to int64; golang cast int to int64; strconv round trip; portability when int is 32 …
Convert float64 to int or int64 in Go (cast, round, strconv)
Golang float64 to int and golang float64 to int64: convert with int()/int64() truncation, math.Round for nearest integer, golang convert float to int and golang convert float64 to int safely, plus float64 to int golang …
Golang CPU affinity on Linux: sched_setaffinity, taskset, GOMAXPROCS
Golang CPU affinity on Linux: cpu masking with golang.org/x/sys/unix SchedSetaffinity, taskset from Go, runtime.LockOSThread for set thread affinity, and why gomaxprocs golang is not affinity.
FlashDB in Go: in-memory key-value store with optional persistence
FlashDB golang tutorial: an in memory database golang option and golang key value store with Redis-style types. Covers go in memory database setup, transactions, string SET/GET/DELETE, disk vs pure memory, and links for …
Golang nil checks: pointers, interfaces, slices, and empty structs
Golang check if nil for pointers and maps; golang null pointer with == nil; check if slice is empty golang (len vs nil); golang check if struct is empty (not nil—reflect.IsZero); golang check if interface is nil …
Go HTTPS Client: Skip TLS Verify (InsecureSkipVerify) and Safer Options
Use tls.Config InsecureSkipVerify on a dedicated net/http Transport for golang http client skip tls verify only in dev; prefer fixing golang ssl certificate trust with RootCAs instead of golang disable ssl verification …
Golang flag package examples: CLI flags, multiple values, subcommands
Golang flag and golang flags examples using the standard library flag package: go flag and go CLI flags, golang flag example for string, int, and bool, golang flag multiple values with flag.Value, required flags, …
Golang seek on files: os.File.Seek and whence constants
Golang file seek and go file seek with (*os.File).Seek: io.SeekStart, io.SeekCurrent, io.SeekEnd, temp-file examples, and bytes.Reader for in-memory golang seek.
GraphQL in Go: golang graphql tutorial, examples, and HTTP server
Graphql golang tutorial and golang graphql example with github.com/graphql-go/graphql: schema, resolvers, graphql.Do, context, HTTP handler and Playground, go graphql patterns, graphql golang vs REST, and graphql mongodb …
Golang break and continue: inner loop, outer loop, and select
Golang break and golang continue for go break loop and golang break for loop; golang break outer loop and golang continue outer loop with labels; golang select break exits the select—use a label to leave the surrounding …

