Go for mobile development: backend, API and utilities

Author: IT Sectr Published: 2026-02-11 Reading time: 10 min

Go is a compiled programming language from Google, created in 2009 by Robert Griesemer, Rob Pike and Ken Thompson. Go combines syntax simplicity with C-level performance. In mobile development, Go is used for backend, microservices, API gateways and CLI utilities. According to Stack Overflow Survey (2025), Go is among the top ten highest-paying programming languages.

Key takeaways

  • Go is a compiled language with static typing, built-in concurrency support and fast build times
  • Goroutines are lightweight threads for concurrent execution, consuming ~4 KB per goroutine
  • Backend in Go provides high performance microservices for mobile applications
  • CLI utilities in Go compile into a single static binary with no external dependencies
  • Gomobile allows compiling Go code into native .aar and .xcframework libraries

What is Go?

Go is a statically typed compiled language with automatic memory management via garbage collection. Go's main goals: fast compilation, code simplicity and built-in concurrency support. Go compiles into a native binary without a virtual machine — one executable file contains everything, including dependencies.

The Go standard library covers HTTP server, JSON marshaling, command-line flag parsing, encryption and database operations. No external framework is needed for an HTTP server — net/http is built-in. Go Modules (since v1.16) is the standard dependency management system. The current version is Go 1.23 (2025) with an improved iter package for iterators.

Go was designed to solve the scaling problems Google encountered: slow C++ compilation, Java complexity, inefficient Python concurrency. The result is a language that powers Docker, Kubernetes, Prometheus, Terraform and Hugo.

Go syntax

Go is minimalist: 25 keywords (compared to 84 in C++). There are no classes, inheritance, generics (until v1.18), operator overloading or exceptions. Errors are handled explicitly via error returns. Structs and interfaces replace OOP.

go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
)

type User struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

func userHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json")
	user := User{ID: 1, Name: "Alice", Email: "alice@example.com"}
	json.NewEncoder(w).Encode(user)
}

func main() {
	http.HandleFunc("/api/user", userHandler)
	fmt.Println("Server on :8080")
	http.ListenAndServe(":8080", nil)
}

The User struct with JSON tags defines serialization. http.HandleFunc registers a handler. json.NewEncoder(w).Encode(user) serializes the struct to JSON directly into the response. The built-in HTTP server handles requests in separate goroutines automatically.

Goroutines and channels: Go concurrency model

Goroutines are lightweight execution threads managed by the Go runtime. Unlike OS threads (1–8 MB stack), a goroutine starts with a 4 KB stack that grows dynamically. You can run 100,000 goroutines on a single server. Starting a goroutine — go functionName().

Channels are typed queues for passing data between goroutines. A channel is created via make(chan Type). The <- operator sends data, <-chan receives it. Channels can be buffered (with capacity) or unbuffered (synchronous).

go
package main

import (
	"fmt"
	"net/http"
	"time"
)

func fetchURL(url string, ch chan<- string) {
	start := time.Now()
	resp, err := http.Get(url)
	if err != nil {
		ch <- fmt.Sprintf("Error: %s", err)
		return
	}
	defer resp.Body.Close()
	elapsed := time.Since(start)
	ch <- fmt.Sprintf("%s — %dms", url, elapsed.Milliseconds())
}

func main() {
	urls := []string{"https://google.com", "https://github.com", "https://stackoverflow.com"}
	ch := make(chan string, len(urls))

	for _, url := range urls {
		go fetchURL(url, ch)
	}

	for range urls {
		fmt.Println(<-ch)
	}
}

Three requests execute concurrently via go fetchURL. The ch channel collects results. defer resp.Body.Close() ensures the response is closed when returning from the function. select {} is not used since all goroutines send to the channel — the main goroutine reads exactly len(urls) times.

Go for mobile app backend

Go is one of the best languages for mobile app backend. Built-in HTTP/2 and HTTP/3, fast protobuf/gRPC serialization and low memory footprint make Go ideal for APIs serving thousands of mobile clients.

Popular frameworks: Gin (up to 10x faster than Express.js), Echo (minimalist, JWT middleware), Fiber (Express-like), Chi (net/http compatible). Gin is the most popular with 70k+ GitHub stars. For gRPC, google.golang.org/grpc is used.

go
package main

import (
	"database/sql"
	"log"
	"net/http"
	"time"

	"github.com/gin-gonic/gin"
	_ "github.com/mattn/go-sqlite3"
)

func main() {
	db, err := sql.Open("sqlite3", "mobile_app.db")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	r := gin.Default()
	r.GET("/api/v1/posts", func(c *gin.Context) {
		type Post struct {
			ID        int       `json:"id"`
			Title     string    `json:"title"`
			CreatedAt time.Time `json:"created_at"`
		}
		rows, _ := db.Query("SELECT id, title, created_at FROM posts ORDER BY created_at DESC LIMIT 20")
		defer rows.Close()

		var posts []Post
		for rows.Next() {
			var p Post
			rows.Scan(&p.ID, &p.Title, &p.CreatedAt)
			posts = append(posts, p)
		}
		c.JSON(http.StatusOK, posts)
	})
	r.Run(":8080")
}

Gin.GET registers a route with a handler. sql.Open opens an SQLite database, db.Query executes a query. c.JSON serializes the posts slice into a JSON array. The anonymous function inside GET captures db from the outer context. Gin handles panics, logs requests and supports middleware.

Microservices and API gateways in Go

Go is the primary language for microservice architecture. Low memory consumption per microservice (15–30 MB) allows dozens of services to run on a single server. Fast startup (milliseconds) and small binary size (10–20 MB) simplify container deployment.

An API Gateway in Go aggregates requests from a mobile app to internal services. A Go gateway handles authentication (JWT), rate limiting, routing and caching. Popular implementations: Kong (based on OpenResty with Go plugins), Tyk (in Go), custom gateways on Gin.

gRPC and protobuf

gRPC is a remote procedure call framework from Google using Protocol Buffers for serialization and HTTP/2 for transport. Go has the best gRPC support among all languages. For mobile backends, gRPC provides 5–10x higher throughput than REST/JSON.

go
package main

import (
	"context"
	"log"
	"net"

	"google.golang.org/grpc"
	pb "example.com/proto"
)

type server struct {
	pb.UnimplementedUserServiceServer
}

func (s *server) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.UserResponse, error) {
	return &pb.UserResponse{
		Id:    req.Id,
		Name:  "Alice",
		Email: "alice@example.com",
	}, nil
}

func main() {
	lis, _ := net.Listen("tcp", ":50051")
	s := grpc.NewServer()
	pb.RegisterUserServiceServer(s, &server{})
	log.Fatal(s.Serve(lis))
}

pb.UnimplementedUserServiceServer is a stub generated by protoc from the .proto file. The server structure overrides the GetUser method. grpc.NewServer() creates a server with interceptors for logging, authentication and metrics.

Go for CLI utilities and developer tools

Go is the best language for CLI utilities used in mobile development. A single static binary (~10 MB) with no dependencies runs on all platforms: macOS, Linux, Windows. Compilation takes seconds. Go utilities do not require an interpreter or runtime installation.

Examples of Go tools in the mobile ecosystem: Migrate (DB migrations), Kubectl (Kubernetes for mobile backend), Terraform (infrastructure), Prometheus (monitoring). Developers write Go utilities for generating models from proto files, validating configurations and deploying microservices.

go
package main

import (
	"flag"
	"fmt"
	"os"
)

func main() {
	project := flag.String("project", "", "Project directory")
	version := flag.String("version", "1.0.0", "App version")
	verbose := flag.Bool("verbose", false, "Verbose output")
	flag.Parse()

	if *project == "" {
		fmt.Println("Usage: deploy --project=path [--version=x.x.x]")
		os.Exit(1)
	}

	if *verbose {
		fmt.Printf("Deploying project %s version %s\n", *project, *version)
	}
	// deployment logic here
	fmt.Println("Deploy complete")
}

flag.String defines a string command-line flag with a name, default value and description. flag.Parse() parses os.Args arguments. Pointers *project are dereferenced to get values. The binary is built with go build -o deploy deploy.go.

Gomobile: Go in native libraries for iOS and Android

Gomobile is a Google tool for compiling Go code into native mobile libraries. go bind -target=android generates .aar for Android, go bind -target=ios generates .xcframework for iOS. This lets you write common business logic in Go and call it from Kotlin and Swift.

Main Gomobile use cases: cryptography (custom encryption schemes), networking (custom WebSocket protocols), data processing (compression, encoding, parsing). UI is not written in Go — its purpose is to replace C++ for cross-platform native modules.

go
package mobile

import "crypto/aes"

// EncryptData encrypts data with AES-256-GCM (exported to .aar)
func EncryptData(key []byte, plaintext []byte) ([]byte, error) {
	block, err := aes.NewCipher(key)
	if err != nil {
		return nil, err
	}
	ciphertext := make([]byte, len(plaintext))
	block.Encrypt(ciphertext, plaintext)
	return ciphertext, nil
}

func DecryptData(key []byte, ciphertext []byte) ([]byte, error) {
	block, err := aes.NewCipher(key)
	if err != nil {
		return nil, err
	}
	plaintext := make([]byte, len(ciphertext))
	block.Decrypt(plaintext, ciphertext)
	return plaintext, nil
}

Exported functions (capital letters) are wrapped by Gomobile into Java/Swift interfaces. From Kotlin, the call looks like Mobile.encryptData(key, plaintext). Gomobile automatically converts types: []byte → byte[] (Java) / Data (Swift).

CommandResultPlatform
gomobile bind -target=android.aar libraryAndroid
gomobile bind -target=ios.xcframeworkiOS
gomobile build -target=android.apk with Go activityAndroid

Go vs Java and Kotlin for backend: comparison

Go competes with Java and Kotlin in server development. Key differences: Go compiles into a native binary, does not require a JVM, consumes 2–3x less memory and starts in milliseconds. Java wins in ecosystem maturity and the number of libraries.

CriterionGoJava / Kotlin
CompilationNative binary (~10 MB)JVM bytecode + JIT
Startup1–5 ms1–5 s (JVM startup)
RAM usage15–30 MB per service50–200 MB per service
ConcurrencyGoroutines (built-in)Coroutines / RxJava
EcosystemGrowing, 100k+ repositoriesMature, millions of libraries
Learning curve2–4 weeks6–12 months (Java)

Go is chosen for microservices, API gateways and tools. Java/Kotlin — for enterprise applications with rich business logic. In mobile development, the optimal stack is: Go for backend, Kotlin/Swift for client.

Frequently asked questions

How is Go different from Java and Kotlin for server development?

Go compiles into a single static binary without a JVM, consumes less memory and starts faster. Asynchronicity via goroutines is easier than RxJava or Kotlin coroutines. For microservices, Go is chosen for its simplicity and performance.

What Go frameworks are used for mobile app backend?

The most popular: Gin (high performance), Echo (minimalist), Fiber (Express.js style), Chi (lightweight and compatible). For real-time, WebSocket Gorilla or Melody is used. For gRPC — google.golang.org/grpc.

Can you write mobile applications in Go?

Yes, through Gomobile you can compile Go into .aar (Android) and .xcframework (iOS). However, UI is not written in Go — it is not practical due to the limited ecosystem. Go is effective for native libraries, cryptography and networking.

Is Go suitable for high-load projects?

Yes, Go was designed for high-load systems. Companies like Cloudflare, Uber, Twitch, Dropbox use Go in production. The built-in goroutine scheduler handles millions of concurrent tasks on a single server.

Is Go hard to learn after Java or Kotlin?

Go is simpler than Java — it has no classes, inheritance or exceptions. The syntax is minimalist, structs and interfaces replace OOP. Most developers learn Go in 2–4 weeks.

Summary

  • Go is a compiled language with static typing, built-in goroutines and fast compilation into a native binary
  • Goroutines and channels are a concurrency model that handles millions of tasks with minimal memory consumption
  • Backend in Go is built with Gin/Echo/Fiber, connecting SQL and Redis through standard drivers
  • Microservices in Go start in milliseconds, consume 15–30 MB and run in containers
  • gRPC and protobuf are the optimal transport for Go mobile backends with high throughput
  • Gomobile compiles Go into .aar and .xcframework for cross-platform native libraries
  • Go vs Java: Go starts faster and is lighter, Java has a richer ecosystem; the optimal stack is Go for backend, Kotlin/Swift for client

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also