pairs

package
v0.0.0-...-b8baac5 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

package pairs allows detecting broken key/value pairs.

A key is defined as a string and a value can be anything.

A missing value is an error:

logger.Log("name", "frew", "job", "engineer", "age") // missing value

A non-string is also an error:

                                     		// missing key
	logger.Log("message", "successful!",                    3)

The sole analyzer (from NewAnalyzer) in this package takes a -pair-flag flag that can define any number of the following:

1. Any method named Log, start pairs at 0:

-pair-func .Log=0

2. The Wrap func from the go.zr.org/common/go/errors package, start pairs at 2:

-pair-func go.zr.org/common/go/errors.Wrap=2

3. The AddPairs method from the go.zr.org/common/go/errors/details.Pairs type, start pairs at 0:

-pair-func go.zr.org/common/go/errors/details.Pairs.AddPairs=0

The other flag defined by this package is -assume-pair flag, which users can use to define type "safe" for passing around. The idea is that you'd define all methods on the type as pair funcs; this means you are passing around the value instead of a raw slice of interfaces, which could get modified in surprising ways by users.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnalyzer

func NewAnalyzer() *analysis.Analyzer

NewAnalyzer returns a fresh pairs analyzer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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