goconst

package
v2.0.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: MIT, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package goconst finds repeated strings that could be replaced by a constant.

There are obvious benefits to using constants instead of repeating strings, mostly to ease maintenance. Cannot argue against changing a single constant versus many strings. While this could be considered a beginner mistake, across time, multiple packages and large codebases, some repetition could have slipped in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstType

type ConstType struct {
	token.Position
	Name string
	// contains filtered or unexported fields
}

type Constants

type Constants map[string]ConstType

type ExtendedPos

type ExtendedPos struct {
	token.Position
	// contains filtered or unexported fields
}

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func New

func New(path, ignore string, ignoreTests, matchConstant, numbers bool, minLength int) *Parser

New creates a new instance of the parser. This is your entry point if you'd like to use goconst as an API.

func (*Parser) ParseTree

func (p *Parser) ParseTree() (Strings, Constants, error)

ParseTree will search the given path for occurrences that could be moved into constants. If "..." is appended, the search will be recursive.

type Strings

type Strings map[string][]ExtendedPos

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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