How to use this

Every library is an ordinary, dependency-free Go module — install what you need with go get, import it, and go. Below is one worked example per category; open any library tab for its full API reference.

1 · Install

Pick any subset — they're independent modules, all under github.com/malcolmston/<name>.

shell
go get github.com/malcolmston/express      # web framework
go get github.com/malcolmston/socketio     # real-time
go get github.com/malcolmston/passport     # auth
go get github.com/malcolmston/algebra      # symbolic + numeric math
go get github.com/malcolmston/sqlite       # embedded SQL
go get github.com/malcolmston/chalk        # terminal styling
# …38 libraries in total

2 · A minimal web server (express)

main.go
package main

import (
    "log"
    "github.com/malcolmston/express"
)

func main() {
    app := express.New()
    app.Get("/", func(req *express.Request, res *express.Response, next express.Next) {
        res.Send("Hello World")
    })
    app.Get("/users/:id", func(req *express.Request, res *express.Response, next express.Next) {
        res.JSON(map[string]any{"id": req.Param("id")})
    })
    log.Fatal(app.Listen(":3000"))
}

3 · The full real-time stack

Express serves the API, morgan logs every request, and Socket.IO handles realtime — all on one net/http server. This is the runnable examples/integration in the repo.

go
app := express.New()
app.Get("/api/hello", func(req *express.Request, res *express.Response, next express.Next) {
    res.JSON(map[string]any{"msg": "hi"})
})

io := socketio.New()
io.OnConnection(func(s *socketio.Socket) {
    s.On("chat", func(args []any) []any { io.Emit("chat", args...); return nil })
})

logged := morgan.New(io.Handler(app), morgan.Dev, morgan.Config{})
http.ListenAndServe(":3000", logged)
Because every library is an http.Handler (or produces one), they compose the same way any Go middleware does — no framework lock-in.

4 · Authentication (passport + jwt)

Passport's strategies plug into Express; issue and verify tokens with the jwt library.

go
// Sign & verify a JSON Web Token
tok, _ := jwt.Sign(jwt.Claims{"sub": "alice"}, "secret", jwt.HS256)
claims, err := jwt.Verify(tok, "secret")

// Protect a route with a passport strategy
p := passport.New()
p.Use(bearer.New(func(token string) (any, error) {
    return lookupUser(token)
}))
app.Get("/me", p.Authenticate("bearer"), func(req *express.Request, res *express.Response, next express.Next) {
    res.JSON(req.User())
})

5 · Math & data (algebra, numpy, pandas)

algebra is 100+ stdlib-only subpackages spanning number theory, linear algebra, calculus, statistics and much more.

go
import (
    "github.com/malcolmston/algebra/ntheory"
    "github.com/malcolmston/algebra/matrix"
    "github.com/malcolmston/numpy"
)

func main() {
    fmt.Println(ntheory.Binomial(52, 5))          // 2598960
    fmt.Println(ntheory.Factorial(10))            // 3628800

    a := matrix.FromFloats([][]float64{{1, 2}, {3, 4}})
    det, _ := a.DetLU()                           // -2

    v := numpy.Arange(0, 10, 1)
    fmt.Println(numpy.Mean(v))                    // 4.5
}

6 · Data stores (sqlite + redis)

go
db, _ := sqlite.Open("app.db")
db.Exec("CREATE TABLE users (id INTEGER, name TEXT)")
db.Exec("INSERT INTO users VALUES (?, ?)", 1, "alice")
rows, _ := db.Query("SELECT name FROM users WHERE id = ?", 1)

cache := redis.New()
cache.Set("greeting", "hi", 0)
val, _ := cache.Get("greeting")   // "hi"

7 · Terminal styling (chalk)

go
c := chalk.New()
fmt.Println(c.Red().Bold().Sprint("error:"), "something broke")
fmt.Println(c.Green("ok"), c.Dim("(cached)"))
fmt.Println(c.Hex("#ffa657").Underline().Sprint("custom color"))

8 · HTTP client & HTML (axios + cheerio)

go
client := axios.Create(axios.Config{BaseURL: "https://api.example.com"})
resp, _ := client.Get("/users", nil)

doc, _ := cheerio.LoadHTML(resp.Text())
doc.Find("h1").Each(func(i int, el *cheerio.Selection) {
    fmt.Println(el.Text())
})

9 · Testing & utilities (jest + lodash)

go
// Jest-style expectations in a normal Go test
func TestSum(t *testing.T) {
    jest.Expect(t, sum(2, 3)).ToBe(5)
    jest.Expect(t, []int{1, 2, 3}).ToContain(2)
}

// lodash helpers, generic and type-safe
evens := lodash.Filter([]int{1, 2, 3, 4}, func(n int) bool { return n%2 == 0 })
groups := lodash.GroupBy(words, func(w string) int { return len(w) })

10 · Where to go next

  • Open a library tab above for its full inline API reference, feature list and a Node-vs-Go comparison.
  • Each library tab also shows its live upstream-parity score and the pipeline that produces it.
  • Every repo ships the same API reference on its own GitHub Pages site (linked in each tab), and runnable examples/ live in each repository.
How-to