Skip to content

go-singleuse

Runs singleuse, the analyzer that names the line where a StartFunc captures a server, listener or supervisor a restart cannot reuse. It comes from the nested module gitlab.com/phpboyscout/go/controls/lint; the job go installs it into the cached GOBIN and runs the binary, so a consumer installs nothing. Not go run, which reports a non-zero child as its own exit code 1 and would hide the contract below. What it flags, and why, is on go/controls: Find a capture a restart cannot reuse.

Advisory. The analyzer exits 3 when it reported a finding, and the job tolerates exactly that exit code, so a finding shows as a warning on the pipeline and blocks nothing. Any other failure (the module version does not resolve, the packages do not compile, the image is broken) fails the job, so the day the analyzer stops running is not a quiet one. See spec 0080.

Jobs

Job What it runs
singleuse go install gitlab.com/phpboyscout/go/controls/lint/cmd/singleuse@$[[ inputs.version ]], then cd $[[ inputs.dir ]] && $GOBIN/singleuse $[[ inputs.paths ]], with the same ${CI_PROJECT_PATH_SLUG}-go cache as go-lint (GOBIN under it). allow_failure: exit_codes: [3].

Inputs

Input Type Default Description
image string go-tools:v0.5.0 Go toolchain image.
stage string lint GitLab CI stage.
version string "v0.7.0" The query after @ in go install. Given without the lint/ prefix the tag carries — the Go proxy maps lint/v0.7.0 to v0.7.0 for the nested module. Renovate tracks it against the go datasource. latest still works if you want the newest.
dir string "." Directory to run in, for a consumer that is itself a nested module.
paths string "./..." Go path expression(s), space-separated.
if string '$CI_PIPELINE_SOURCE == "merge_request_event"' Gating rules:if: expression.
changes array ["**/*.go", "**/go.mod", "**/go.sum", ".gitlab-ci.yml"] Change-detection paths.

Usage

include:
  - component: gitlab.com/phpboyscout/cicd/go-singleuse@main

Pin version once the analyzer has a released tag:

include:
  - component: gitlab.com/phpboyscout/cicd/go-singleuse@main
    inputs:
      version: "v0.6.0"

See also