TS
GO

TypeScript to Go

10 lessons

Progress0%
1Introduction: Transpiled to Compiled Binary2Type Systems: Structural Interfaces3Functions4Objects to Structs5Generics6Error Handling7Async to Goroutines8Ecosystem9Testing10Go Standard Library
All Mirror Courses
TS
GO
Ecosystem
MirrorLesson 8 of 10
Lesson 8

Ecosystem

Ecosystem & Tooling

Introduction

In this lesson, you'll learn about ecosystem in Go. Coming from TypeScript, you already have a foundation for understanding this concept. We'll build on that knowledge while highlighting the key differences.

Mirror Card
TS
From TypeScript:

In TypeScript, you're familiar with ecosystem & tooling.

GO
In Go:

Go has its own approach to ecosystem & tooling, which we'll explore step by step.

The Go Way

Let's see how Go handles this concept. Here's a typical example:

GO
Go Example
// go.mod — Go modules manage dependencies
// go get github.com/gin-gonic/gin

package main

import (
    "net/http"
    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.Default()
    r.GET("/users/:id", func(c *gin.Context) {
        id := c.Param("id")
        user := db.Find(id)
        c.JSON(http.StatusOK, user)
    })
    r.Run(":3000")
}

Comparing to TypeScript

Here's how you might have written similar code in TypeScript:

TS
TypeScript (What you know)
// package.json — npm manages dependencies
// npm install express axios

import express from "express";

const app = express();
app.get("/users/:id", async (req, res) => {
  const user = await db.find(Number(req.params.id));
  res.json(user);
});

app.listen(3000);
Mirror Card
TS
From TypeScript:

You may be used to different syntax or behavior.

GO
In Go:

go.mod and go.sum replace package.json and package-lock.json

Mirror Card
TS
From TypeScript:

You may be used to different syntax or behavior.

GO
In Go:

go get downloads and adds dependencies; no separate install step needed

Mirror Card
TS
From TypeScript:

You may be used to different syntax or behavior.

GO
In Go:

Go standard library is comprehensive — net/http, encoding/json, crypto built-in

Mirror Card
TS
From TypeScript:

You may be used to different syntax or behavior.

GO
In Go:

Popular web frameworks: Gin, Fiber, Echo (like Express); standard library also works for simple APIs

Step-by-Step Breakdown

1. Go Modules

Go modules use go.mod (like package.json) and go.sum (like package-lock.json). Initialize with go mod init module/name. Dependencies are fetched with go get.

TS
TypeScript
npm init
npm install express
GO
Go
go mod init github.com/me/myapp
go get github.com/gin-gonic/gin
Rule of Thumb
Module names are conventionally the repository URL (github.com/user/repo).

2. Standard Library Is Comprehensive

Go's standard library includes net/http (HTTP server and client), encoding/json, database/sql, crypto, testing, and more. Many Node.js apps need Express; many Go apps only need net/http.

TS
TypeScript
import express from "express"; // third-party required
GO
Go
import "net/http" // built-in HTTP server

http.HandleFunc("/", handler)
http.ListenAndServe(":3000", nil)

3. go test — Testing Built In

Go's testing package is part of the standard library. Test files end in _test.go. Run with go test ./... No Jest or Vitest needed.

TS
TypeScript
// jest.config.ts + import { it, expect } from "@jest/globals"
it("adds", () => expect(add(1, 2)).toBe(3));
GO
Go
// add_test.go — same package
func TestAdd(t *testing.T) {
    if add(1, 2) != 3 {
        t.Errorf("expected 3")
    }
}

// Run: go test ./...

4. Go Use Cases

Go excels at cloud infrastructure, CLI tools, APIs with high concurrency, and container tooling (Docker and Kubernetes are written in Go). TypeScript dominates web front-ends and Node.js backends.

TS
TypeScript
// TypeScript/Node: web apps, SPAs, serverless, full-stack JS
GO
Go
// Go: cloud infra (K8s, Docker), CLI tools,
// high-throughput APIs, network services,
// system-level tooling
Rule of Thumb
Choose Go when you need a single deployable binary, high concurrency, or low memory footprint. TypeScript for web, Go for infrastructure.

Common Mistakes

When coming from TypeScript, developers often make these mistakes:

  • go.mod and go.sum replace package.json and package-lock.json
  • go get downloads and adds dependencies; no separate install step needed
  • Go standard library is comprehensive — net/http, encoding/json, crypto built-in
Common Pitfall
Don't assume Go works exactly like TypeScript. While the concepts may be similar, the syntax and behavior can differ significantly.

Key Takeaways

  • go.mod replaces package.json; go get adds dependencies
  • Go standard library is comprehensive — many apps need no third-party web framework
  • Testing is built in: _test.go files, go test ./... command
  • Go excels at cloud infrastructure, CLI tools, and high-concurrency APIs
Rule of Thumb
The best way to learn is by doing. Try rewriting some of your TypeScript code in Go to practice these concepts.
PreviousNext