--- title: Go description: Install the MockServer Go client module from pkg.go.dev to drive MockServer from Go tests — zero third-party dependencies and an on-demand binary launcher. layout: page pageOrder: 6.3 section: 'Where' subsection: true sitemap: priority: 0.6 changefreq: 'monthly' lastmod: 2026-06-11T08:00:00+01:00 ---
The mockserver-client-go module provides an idiomatic Go client for MockServer's control-plane REST API. It has zero third-party runtime dependencies (pure net/http + encoding/json) and includes an on-demand binary launcher that starts MockServer without Java or Docker.
go get github.com/mock-server/mockserver-monorepo/mockserver-client-go/v7@latest
package main
import (
"log"
mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v7"
)
func main() {
client := mockserver.New("localhost", 1080)
// Create an expectation
_, err := client.When(
mockserver.Request().Method("GET").Path("/hello"),
).Respond(
mockserver.Response().StatusCode(200).Body("world"),
)
if err != nil {
log.Fatal(err)
}
// Verify the request was received at least once
if err := client.Verify(
mockserver.Request().Path("/hello"),
mockserver.AtLeast(1),
); err != nil {
log.Fatal(err)
}
// Reset
client.Reset()
}
The module includes a binary launcher — no Java installation or Docker required:
handle, err := mockserver.StartServer(1080, "", nil)
if err != nil {
log.Fatal(err)
}
defer handle.Stop()
fmt.Printf("MockServer running on port %d\n", handle.Port)
See Running MockServer — client library launcher for full launcher options (version pinning, cache directory, air-gapped networks).
For the full Go client API, see MockServer clients.