Skip to content

Development

Go (version in go.mod), no cgo: every release binary builds with CGO_ENABLED=0 for linux amd64 and arm64. The only exception is the optional PKCS#11 server build.

Build

make build                                               # dist/limdm-{server,agent}-linux-{amd64,arm64}
make build VERSION=0.16.0 UPDATE_PUBKEY=<hex>            # version and release key compiled in
make test                                                # go vet and unit tests
make lint                                                # golangci-lint v2 (.golangci.yml)
make integration DB=postgres://limdm@127.0.0.1:5432/limdm  # TestIntegration against an empty database
make snapshot                                            # goreleaser snapshot: deb, rpm, apk, Arch packages, tar.gz, no publishing
make clean                                               # removes dist/

make build builds only the server and the agent. limdm (the device CLI) and limdm-desktop (the desktop helper) are built by goreleaser (make snapshot) or with go build ./cmd/limdm ./cmd/limdm-desktop. An agent built without UPDATE_PUBKEY refuses every self update (Release key).

PKCS#11 build

The HSM key provider (LIMDM_KEY_PROVIDER=pkcs11) needs cgo and the build tag pkcs11:

CGO_ENABLED=1 go build -tags pkcs11 -trimpath -ldflags "-s -w" -o limdm-server ./cmd/limdm-server

Without the tag the provider files are left out and the server refuses pkcs11 at start. Details, container image and a SoftHSM test: Separate build.

Tests

Command Runs
go test ./... unit tests; tests that need PostgreSQL or the network skip themselves
LIMDM_TEST_DATABASE_URL=postgres://... go test ./internal/server every database test (integration, API, tenants, keys, HA, remote shell, evidence)
make integration DB=postgres://... only TestIntegration
LIMDM_LIVE_DNS=1 go test -run TestDoHLive ./internal/agent asks the real DNS over HTTPS resolvers
CGO_ENABLED=1 go test -tags pkcs11 ./internal/server PKCS#11 key parsing tests

The database tests drop and recreate the public schema of LIMDM_TEST_DATABASE_URL. Never point them at a database with data. CI runs go test -race -count=1 ./... with a PostgreSQL on the runner, so the database tests run there.

CI also checks go mod tidy -diff, gofmt -l, the cross compile for amd64 and arm64, go vet, golangci-lint, govulncheck, goreleaser check, actionlint and zizmor for the workflows, and a dependency review with a license allowlist on pull requests.

Lint

make lint runs golangci-lint at the version pinned in the Makefile and in CI, with the configuration in .golangci.yml (nolintlint is on: an exception is a //nolint:<linter> // reason comment on the line).