golintx

package module
v0.0.0-...-1847c09 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: BSD-3-Clause Imports: 20 Imported by: 0

README

wercker status

Original: https://github.com/golang/lint

Golintx is a linter for Go source code.

Differences From Original golint

  • Support per-directory config files
    • if a config file on lint-target directory does not exists, search files in ancestor directories recursively.
  • exit(1) if any problem exists
  • Support multi directories on command line
    • ex: golintx $(glide novendor)

Installation

Golintx requires Go 1.6 or later.

go get -u github.com/haruyama/golintx/golintx

Config File (.golintx.hcl)

exclude {
        // array of categories which golintx does not report
        categories = ["comments"]
}
// array of initialisms
initialisms = [
        "API",
        "ASCII",
        "CPU",
        "CSS",
        "DNS",
        "EOF",
        "GUID",
        "HTML",
        "HTTP",
        "HTTPS",
        // "ID",
        "IP",
        "JSON",
        "LHS",
        "QPS",
        "RAM",
        "RHS",
        "RPC",
        "SLA",
        "SMTP",
        "SQL",
        "SSH",
        "TCP",
        "TLS",
        "TTL",
        "UDP",
        "UI",
        "UID",
        "UUID",
        // "URI",
        // "URL",
        "UTF8",
        "VM",
        "XML",
        "XSRF",
        "XSS",
]

Documentation

Overview

Package golintx 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 Config

type Config struct {
	Exclude     ExcludeConfig
	Initialisms []string
}

A Config holds golintx config

type ExcludeConfig

type ExcludeConfig struct {
	Categories []string
}

A ExcludeConfig holds "exclude" section in config

type Linter

type Linter struct {
}

A Linter lints Go source code.

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