Skip to content

sivchari/containedctx

Repository files navigation

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@latest

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` ./...

About

containedctx is a linter that detects struct contained context.Context field

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy