reqfields

package module
v0.0.0-...-2d83eae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 6 Imported by: 0

README

go-reqfields

Go linter for missing required struct fields.

example

Installation

go get github.com/colinking/go-reqfields

Usage

go run ./cmd/reqfields <pkg | file>
# Example:
go run ./cmd/reqfields ./fixtures/ex1

IDE Integration

You can configure your editor to provide lint warnings from go-reqfields via golangci-lint.

To do that, first download this repo and run go generate ./.... This will generate a Go plugin that golangci-lint will use.

Then, add a .golangci.yml to your repo with the following configuration:

linters-settings:
  custom:
    reqfields:
      # Make sure to update this path to point at your local copy of `colinking/go-reqfields`:
      path: ./cmd/plugin/main.so
      description: Compile-time warnings for required fields.
      original-url: github.com/colinking/go-reqfields

linters:
  enable:
    - reqfields

Finally, configure your editor to use golangci-lint. For example in VSCode, you add the following to your settings file:

"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"],

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "reqfields",
	Doc:  "reports missing required struct fields",
	Run:  run,
}

Functions

This section is empty.

Types

type Struct

type Struct struct {
	Name           string
	RequiredFields []string
}

Directories

Path Synopsis
cmd
fixtures
ex1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL