Back to rankings

Go package for OCR (Optical Character Recognition), by using Tesseract C++ library

gotesseracttesseract-ocrocrocr-server
Star Growth
Stars
3.1k
Forks
307
Weekly Growth
Issues
27
1k2k3k
Jan 2014Mar 2018May 2022Jul 2026
ArtifactsGo Modulesgo get github.com/otiai10/gosseract
README

gosseract OCR

Go Test Docker Test BSD Test Windows Test codecov Go Report Card License: MIT Go Reference

Golang OCR package, by using Tesseract C++ library.

OCR Server

If you need an OCR server or want to see a working example of this package, there is a ready-made server application, which is very easy to deploy!

👉 https://github.com/otiai10/ocrserver

Example

package main

import (
	"fmt"
	"github.com/otiai10/gosseract/v2"
)

func main() {
	client := gosseract.NewClient()
	defer client.Close()
	client.SetImage("path/to/image.png")
	text, _ := client.Text()
	fmt.Println(text)
	// Hello, World!
}

Installation

macOS

brew install tesseract
go get -t github.com/otiai10/gosseract/v2

Linux (Debian/Ubuntu)

sudo apt-get install -y libtesseract-dev libleptonica-dev tesseract-ocr-eng
go get -t github.com/otiai10/gosseract/v2

Please check this Dockerfile to get started. Alternatively, you can deploy the pre-existing Docker image by invoking docker run -it --rm otiai10/gosseract.

Windows

Windows support requires vcpkg and MinGW-w64:

# Install Tesseract via vcpkg
vcpkg install tesseract:x64-windows

# Create MinGW import libraries from vcpkg DLLs
cd C:/vcpkg/installed/x64-windows/bin
gendef tesseract55.dll leptonica-1.87.0.dll
dlltool -d tesseract55.def -l libtesseract.a -D tesseract55.dll
dlltool -d leptonica-1.87.0.def -l libleptonica.a -D leptonica-1.87.0.dll
mv *.a ../lib/

# Download language data
mkdir C:/tessdata
curl -L -o C:/tessdata/eng.traineddata https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata

Set environment variables before building:

export CGO_ENABLED=1
export CC=C:/mingw64/bin/gcc.exe
export CGO_CFLAGS="-IC:/vcpkg/installed/x64-windows/include"
export CGO_LDFLAGS="-LC:/vcpkg/installed/x64-windows/lib"
export TESSDATA_PREFIX="C:/tessdata"
export PATH="/c/mingw64/bin:/c/vcpkg/installed/x64-windows/bin:$PATH"

For detailed troubleshooting, see knowledge/windows-support.md.

Test

In case you have tesseract-ocr installed on your local environment, you can run the tests with:

% go test .

If you DON'T want to install tesseract-ocr on your local environment, run ./test/runtime which utilises Docker and Vagrant to test the source code on some runtimes.

% ./test/runtime --engine docker
% ./test/runtime --engine vagrant

Check ./test/runtimes for more information about runtime tests.

Note: Clear Linux support was removed in January 2026 as Intel discontinued the distribution in July 2025.

Note: Arch Linux support was removed in January 2026 as the official image does not provide ARM64 architecture support.

Issues

Related repositories
avelino/awesome-go

A curated list of awesome Go frameworks, libraries and software

GoGo ModulesMIT Licensegolanggolang-library
awesome-go.com
178.7k13.4k
ollama/ollama

Get up and running with Kimi-K2.6, GLM-5.2, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

GoGo ModulesMIT Licensellamallm
ollama.com
176.5k17k
golang/go

The Go programming language

GoGo ModulesBSD 3-Clause "New" or "Revised" Licenseprogramming-languagelanguage
go.dev
135.3k19.3k
kubernetes/kubernetes

Production-Grade Container Scheduling and Management

GoGo ModulesApache License 2.0kubernetesgo
kubernetes.io
123.8k43.7k
fatedier/frp

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

GoGo ModulesApache License 2.0proxyreverse-proxy
108.2k15.1k
gohugoio/hugo

The world’s fastest framework for building websites.

GoGo ModulesApache License 2.0gohugo
gohugo.io
89k8.3k
gin-gonic/gin

Gin is a high-performance HTTP web framework written in Go. It provides a Martini-like API but with significantly better performance—up to 40 times faster—thanks to httprouter. Gin is designed for building REST APIs, web applications, and microservices.

GoGo ModulesMIT Licenseservermiddleware
gin-gonic.com
88.9k8.6k
syncthing/syncthing

Open Source Continuous File Synchronization

GoGo ModulesMozilla Public License 2.0synchronizationgo
syncthing.net
86.7k5.4k
junegunn/fzf

:cherry_blossom: A command-line fuzzy finder

GoGo ModulesMIT Licensefzfgo
junegunn.github.io/fzf/
81.9k2.8k
grafana/grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

TypeScriptnpmGNU Affero General Public License v3.0grafanamonitoring
grafana.com
75.7k14.3k
caddyserver/caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

GoGo ModulesApache License 2.0goweb-server
caddyserver.com
74.2k4.8k
moby/moby

The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

GoGo ModulesApache License 2.0dockercontainers
mobyproject.org
71.9k19k