woodpecker/vendor/github.com/sivchari/containedctx
6543 1e9119ace9
Update backend dependencies (#898)
* update xorm.io

* update module

* update github.com/docker/cli

* update github.com/docker/distribution

* update github.com/docker/docker

* update github.com/gin-gonic/gin

* update github.com/golang-jwt/jwt/v4

* update github.com/golangci/golangci-lint

* update github.com/gorilla/securecookie

* update github.com/lib/pq

* update github.com/mattn/go-sqlite3

* update github.com/moby/moby

* update github.com/stretchr/testify

* update github.com/urfave/cli/v2

* update github.com/xanzy/go-gitlab

* finish

* update module

* clean
2022-05-05 19:36:49 +02:00
..
.golangci.yml Update deps (#789) 2022-02-24 17:33:24 +01:00
containedctx.go Update deps (#789) 2022-02-24 17:33:24 +01:00
go.mod Update deps (#789) 2022-02-24 17:33:24 +01:00
go.sum Update deps (#789) 2022-02-24 17:33:24 +01:00
LICENCE Update deps (#789) 2022-02-24 17:33:24 +01:00
README.md Update backend dependencies (#898) 2022-05-05 19:36:49 +02:00

containedctx

test_and_lint

containedctx is a linter that detects struct contained context.Context field. This is discouraged technique in favour of passing context as first argument of method or function. For rationale please read Contexts and structs the Go blog post.

Instruction

go install github.com/sivchari/containedctx/cmd/containedctx

Usage

package main

import "context"

type ok struct {
	i int
	s string
}

type ng struct {
	ctx context.Context
}

type empty struct{}
go vet -vettool=(which containedctx) ./...

# a
./main.go:11:2: found a struct that contains a context.Context field

CI

CircleCI

- run:
    name: install containedctx
    command: go install github.com/sivchari/containedctx/cmd/containedctx

- run:
    name: run containedctx
    command: go vet -vettool=`which containedctx` ./...

GitHub Actions

- name: install containedctx
  run: go install github.com/sivchari/containedctx/cmd/containedctx

- name: run containedctx
  run: go vet -vettool=`which containedctx` ./...