How to Convert a Scanned PDF to Word in Go with Tesseract hOCR
Turn a scanned PDF into a .docx with headings, indents, alignment and page breaks intact, in Go with poppler, Tesseract hOCR and archive/zip — Odia or any script.
The language you reach for when a service has to be small, fast to start and boring to operate.
Go is what CodeNx reaches for when a service has to start fast, hold a predictable amount of memory and be operable by somebody who did not write it. The language is deliberately small, the toolchain is one binary, and the output is one more binary with no runtime to install alongside it.
Reach for Go when the workload is concurrent I/O — a proxy, a webhook receiver, an import worker, a CLI shipped to other people’s machines — or when the deployment target rewards a small static binary. Reach for something else when the library you need only exists in npm or PyPI, or when the team writes TypeScript all day and the service is not on a hot path; a language nobody on call reads is a liability regardless of its benchmark numbers.
Version policy first. A major release lands every February and August, and each
one is supported until two newer majors exist — so the supported set is always
the latest two. Record the version in go.mod with the go and toolchain
directives, which makes the build reproducible independent of the image tag.
The Go 1 compatibility promise means these upgrades are usually uneventful;
where they cannot be, the old behaviour stays available through GODEBUG.
The production behaviour that catches people is lifetime, not syntax. A
goroutine that blocks forever is a leak the garbage collector cannot help with,
so every one of them needs a context that is eventually cancelled. http.Server
has no default timeouts at all, which means a client that opens a connection and
sends nothing keeps it. database/sql has no default connection cap, so the
first real traffic spike is felt by the database rather than the service. And
the garbage collector sizes the heap by a growth ratio, so a container memory
limit it does not know about is enforced by the OOM killer instead —
GOMEMLIMIT is how you tell it.
CodeNx does not have standalone Go articles yet. This hub maps the topic and links the primary sources until it does.
Failure modes that come up repeatedly with Go, and where each one is solved.
Turn a scanned PDF into a .docx with headings, indents, alignment and page breaks intact, in Go with poppler, Tesseract hOCR and archive/zip — Odia or any script.
One of the two most recent major releases. Go ships a major release every February and August, and the team supports each one until two newer majors exist, so staying one behind is fine and two behind is unsupported. Pin it with the `go` and `toolchain` lines in `go.mod` rather than whatever the build image happens to have.
Rarely, by design. The Go 1 compatibility promise means programs that build today are meant to keep building on later Go 1 releases. Behaviour changes that cannot be avoided go behind GODEBUG settings, which is worth knowing about before blaming your own code for a post-upgrade regression.
Since Go 1.25 the runtime takes the cgroup CPU bandwidth limit into account when defaulting `GOMAXPROCS`. On older releases it counts host CPUs instead, which over-schedules a limited container, and the usual fix is `go.uber.org/automaxprocs` or setting `GOMAXPROCS` explicitly.
The build produces one statically linked binary, so the runtime image can be `scratch` or distroless with no interpreter, no module tree and no package manager. Build in a full image, copy the binary into an empty one.