lint

package module
v0.0.0-...-7092cbe Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: BSD-3-Clause Imports: 16 Imported by: 0

README

Golinter

Golinter is a fork of golint (github.com/golang/lint). The only difference is that you can specify which linting mistakes to report.

Installation

Golinter will install side-by-side with the official linter. However, since they share the same codebase (Golinter being a fork of the linter) the default functionality should be the same.

go get

Golinter requires a supported release of Go.

go get -u github.com/DylanMeeus/golinter

from source

git clone github.com/DylanMeeus/golinter
cd golinter
go build && go install

Usage

If you're not familiar with go lint read the documentation of golint first.

Golinter let's you specify which linting mistakes to report back. For a list of all flags, you can run golinter -h.

By default, all possible linting mistakes will be reported back. Thus, by default golinter will act the same as golint.

But if we'd want to ignore blank imports and variable declaration errors we could tweak it:

golinter -lint_vardecls=false -lint_blank_imports=false ./...

Available flags

With the following flags you can control which errors to report back:

- lint_blank_imports
- lint_context_args
- lint_context_key_types,
- lint_elses
- lint_error_returns
- lint_error_strings
- lint_errorf
- lint_errors
- lint_exported
- lint_inc_dec
- lint_names
- lint_ranges
- lint_package_comments
- lint_receiver_names
- lint_time_names
- lint_unexported_return
- lint_vardecls

Documentation

Overview

Package lint contains a linter for Go source code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Linter

type Linter struct {
	LintExported         bool // run linter on exported types.
	LintPackageComments  bool
	LintImports          bool
	LintBlankImports     bool
	LintNames            bool
	LintVarDecls         bool
	LintElses            bool
	LintRanges           bool
	LintErrorf           bool
	LintErrors           bool
	LintErrorStrings     bool
	LintReceiverNames    bool
	LintIncDec           bool
	LintErrorReturn      bool
	LintUnexportedReturn bool
	LintTimeNames        bool
	LintContextKeyTypes  bool
	LintContextArgs      bool
}

A Linter lints Go source code.

func NewLinter

func NewLinter() *Linter

NewLinter will create an instance of linter with all checks enabled

func (*Linter) Lint

func (l *Linter) Lint(filename string, src []byte) ([]Problem, error)

Lint lints src.

func (*Linter) LintFiles

func (l *Linter) LintFiles(files map[string][]byte) ([]Problem, error)

LintFiles lints a set of files of a single package. The argument is a map of filename to source.

type Problem

type Problem struct {
	Position   token.Position // position in source file
	Text       string         // the prose that describes the problem
	Link       string         // (optional) the link to the style guide for the problem
	Confidence float64        // a value in (0,1] estimating the confidence in this problem's correctness
	LineText   string         // the source line
	Category   string         // a short name for the general category of the problem

	// If the problem has a suggested fix (the minority case),
	// ReplacementLine is a full replacement for the relevant line of the source file.
	ReplacementLine string
}

Problem represents a problem in some source code.

func (*Problem) String

func (p *Problem) String() string

Directories

Path Synopsis
golint lints the Go source files named on its command line.
golint lints the Go source files named on its command line.

Jump to

Keyboard shortcuts

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