Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
19 posts found
What Is Go and Why Does It Exist? Go's Philosophy, Toolchain and When to Choose It, for C# Developers
Backend PART 01

What Is Go and Why Does It Exist? Go's Philosophy, Toolchain and When to Choose It, for C# Developers

Go is a small, natively compiled language that carries its runtime inside the binary, born at Google as an answer to slow builds and complexity in large codebases. A two-endpoint Bookstore service as a single 9.9 MB Windows .exe that starts in 10 ms and uses 12 MB, a comparison table with ASP.NET Core, go build/vet/fmt/fix/doc, cross-compiling, the six-month release policy and when to choose Go.

15 Nov 2026 14 min 5
Installing Go, Modules and Project Layout: go.mod, Packages, internal/ and cmd/
Backend PART 02

Installing Go, Modules and Project Layout: go.mod, Packages, internal/ and cmd/

A Go module is defined by go.mod: since Go 1.21 the go line is a binding minimum version, go.sum holds a hash for every dependency, and downloads are verified through proxy.golang.org and sum.golang.org. The story of the version go mod init writes, the toolchain line and GOTOOLCHAIN, staticcheck via the tool directive, exporting with uppercase names, the internal/ and cmd/ layout, go work, go mod tidy -diff and Go 1.27 merging require blocks into two.

15 Nov 2026 13 min 4
Go Fundamentals: Types, Zero Values, Slices, Maps, Pointers and Control Flow
Backend PART 03

Go Fundamentals: Types, Zero Values, Slices, Maps, Pointers and Control Flow

In Go a slice is a small header made of a pointer, len and cap, and sub-slices share the same backing array, which is why a filter working on books[:0] corrupts the original catalog. The zero value philosophy, constants with iota, strings vs bytes vs runes and the len trap with Turkish characters, append growing capacity, nil maps and random map order, pointers and Go 1.26's new(expr), the 1.22 loop variable and nil slices turning into null in JSON.

15 Nov 2026 16 min 2
Structs, Methods and Interfaces in Go: OOP Without Classes, Embedding and Implicit Interfaces
Backend PART 04

Structs, Methods and Interfaces in Go: OOP Without Classes, Embedding and Implicit Interfaces

Go has no classes: data lives in structs and behaviour in methods; a method that changes state needs a pointer receiver, and interfaces are implicit and declared small on the side that uses them. Bookstore's order model (NewOrder, embedding Timestamps, MarkPaid), memstore and sqlstore behind orders.Repository, accept interfaces return structs, Stringer, type switches, the method set error and the nil interface trap caught by staticcheck.

15 Nov 2026 15 min 3
Error Handling in Go: Error Values, Wrapping, errors.Is/As/AsType and panic
Backend PART 05

Error Handling in Go: Error Values, Wrapping, errors.Is/As/AsType and panic

In Go an error is a return value: sentinel errors are recognised with errors.Is, custom error types with errors.As or Go 1.26's errors.AsType, and %w adds context while keeping the chain. ErrOutOfStock and ValidationError in Bookstore, collecting validation problems with errors.Join, the trap of wrapping a pointer error with %w and the Go 1.27 vet check that catches it, mapping errors to 404, a handler panic producing an empty reply, and a recover middleware.

15 Nov 2026 15 min 3
Go Generics and Iterators: Type Parameters, Constraints, range-over-func and Generic Methods
Backend PART 06

Go Generics and Iterators: Type Parameters, Constraints, range-over-func and Generic Methods

In Go a constraint is a type set: unless you write ~int64, a named type such as Money cannot be passed to a generic function that asks for int64. Pagination in Bookstore with a generic Page[T], cmp.Ordered and comparable, how Go differs from C# generics (no variance, GC shape stenciling), an iter.Seq iterator that groups books by author, the yield trap, a comparison with the LINQ mindset, and Go 1.27's generic methods.

15 Nov 2026 17 min 3
Goroutines and Channels: Go's Concurrency Model
Backend PART 07

Goroutines and Channels: Go's Concurrency Model

A goroutine is a cheap unit of execution that starts with a 2 KB stack and that the runtime spreads over a few OS threads; a channel is a meeting point between two goroutines that does not behave like a queue. The cost of 100,000 goroutines, the G-M-P scheduler, asynchronous code without async/await, unbuffered and buffered channels, select and timeouts, a table of nil and closed channels, a fan-out/fan-in stock check in Bookstore, and goroutine leaks.

15 Nov 2026 14 min 4
Concurrency Patterns in Go: context, sync, errgroup, Worker Pools and Goroutine Leaks
Backend PART 08

Concurrency Patterns in Go: context, sync, errgroup, Worker Pools and Goroutine Leaks

In Go, data accessed concurrently is either guarded by a mutex or handed to its owner over a channel; an unguarded map crashes the process, while an unguarded counter silently produces duplicate order IDs. Concurrent map writes and the race detector in Bookstore, fixing Service and memstore with mutexes, cancellation and deadlines with context, WaitGroup.Go, a 10,000-invoice worker pool with errgroup, Go 1.27's goroutineleak profile, and running a 15-minute test instantly with synctest.

15 Nov 2026 14 min 4
HTTP Servers with net/http: ServeMux Pattern Routing, Handlers, Middleware and Timeouts
Backend PART 09

HTTP Servers with net/http: ServeMux Pattern Routing, Handlers, Middleware and Timeouts

For an HTTP service in Go the standard library is enough: since 1.22 ServeMux matches method and wildcard patterns with a most-specific-wins rule, and middleware is an ordinary function that wraps a handler. Moving the Bookstore API into the httpapi package, RequestID and Logging middleware, CORS and CrossOriginProtection, the 307 redirect, the pattern conflict panic, WriteTimeout not stopping the handler, and http.Server timeouts against slowloris.

15 Nov 2026 13 min 4
JSON and Request Validation in Go: encoding/json, json/v2, Struct Tags and Body Limits
Backend PART 10

JSON and Request Validation in Go: encoding/json, json/v2, Struct Tags and Body Limits

Reading a JSON body safely in Go takes a Content-Type check, a size limit with MaxBytesReader, DisallowUnknownFields and a single-value check, while encoding/json v1 matches field names regardless of case and takes the last of a repeated field. POST /api/orders in Bookstore, missing values with *int, a validation list from an errors.Join tree, Problem Details with the same contract as ASP.NET Core, Go 1.27's json/v2 differences, and carrying prices in kuruş instead of float64.

15 Nov 2026 14 min 3
From Go to SQL Server and PostgreSQL: database/sql, go-mssqldb, Connection Pools, Transactions and sqlc
Backend PART 11

From Go to SQL Server and PostgreSQL: database/sql, go-mssqldb, Connection Pools, Transactions and sqlc

Go talks to databases through database/sql: sql.Open returns a connection pool rather than a connection, the driver registers through a blank import, and the order plus the stock update go into one transaction with BeginTx, defer Rollback and Commit. Bookstore's orders in SQL Server with go-mssqldb: pool settings, preventing lost updates with a conditional UPDATE, Scanner/Valuer from decimal to kuruş, the rows.Close leak, the datetime2 time zone trap, pgx, and where sqlc stands on SQL Server.

15 Nov 2026 21 min 3
Testing in Go: the testing Package, Table-Driven Tests, httptest, Benchmarks and synctest
Backend PART 12

Testing in Go: the testing Package, Table-Driven Tests, httptest, Benchmarks and synctest

Testing in Go needs no framework: _test.go files, table-driven tests with t.Run, hand-written fakes that satisfy an interface, and httptest are enough. In Bookstore: a table test for the stock rule, a fixed clock, handler tests through the mux, synctest with Go 1.27's httptest.NewTestServer, a fuzz test that finds a negative amount bug, a benchmark of generic code, an integration test against SQL Server, coverage and go test -race.

15 Nov 2026 17 min 3
Blog Map