lint cleanup
This commit is contained in:
		
							parent
							
								
									7106f311ea
								
							
						
					
					
						commit
						2a43b4d109
					
				| 
						 | 
				
			
			@ -6,4 +6,4 @@ before_install:
 | 
			
		|||
- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
 | 
			
		||||
script:
 | 
			
		||||
- go test ./...
 | 
			
		||||
- golangci-lint run --enable-all -D gochecknoglobals -D gomnd
 | 
			
		||||
- golangci-lint run --enable-all
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -108,7 +108,7 @@ func (u *UnifiPoller) ParseConfigs() error {
 | 
			
		|||
	return u.parseOutputs()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// getFirstFile returns the first file that exists and is "reachable"
 | 
			
		||||
// getFirstFile returns the first file that exists and is "reachable".
 | 
			
		||||
func getFirstFile(files []string) (string, error) {
 | 
			
		||||
	var err error
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,9 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
 | 
			
		|||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
 | 
			
		||||
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
 | 
			
		||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
 | 
			
		||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
 | 
			
		||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
 | 
			
		||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +23,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
 | 
			
		|||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 | 
			
		||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
 | 
			
		||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 | 
			
		||||
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
 | 
			
		||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
 | 
			
		||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 | 
			
		||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
			
		||||
| 
						 | 
				
			
			@ -46,18 +49,22 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
 | 
			
		|||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
 | 
			
		||||
github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM=
 | 
			
		||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
 | 
			
		||||
github.com/prometheus/client_golang v1.4.0 h1:YVIb/fVcOTMSqtqZWSKnHpSLBxu8DKgxq8z6RuBZwqI=
 | 
			
		||||
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
 | 
			
		||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
 | 
			
		||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE=
 | 
			
		||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 | 
			
		||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
 | 
			
		||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 | 
			
		||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
 | 
			
		||||
github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY=
 | 
			
		||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
 | 
			
		||||
github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U=
 | 
			
		||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
 | 
			
		||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
 | 
			
		||||
github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
 | 
			
		||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
 | 
			
		||||
github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8=
 | 
			
		||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
 | 
			
		||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 | 
			
		||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
 | 
			
		||||
| 
						 | 
				
			
			@ -103,4 +110,5 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
 | 
			
		|||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
			
		||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
			
		||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
			
		||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
 | 
			
		||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,8 +9,9 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	inputs    []*InputPlugin
 | 
			
		||||
	inputSync sync.Mutex
 | 
			
		||||
	// These are used ot keep track of loaded input plugins.
 | 
			
		||||
	inputs    []*InputPlugin // nolint: gochecknoglobals
 | 
			
		||||
	inputSync sync.Mutex     // nolint: gochecknoglobals
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Input plugins must implement this interface.
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +102,7 @@ func (u *UnifiPoller) Metrics() (*Metrics, bool, error) {
 | 
			
		|||
	var err error
 | 
			
		||||
 | 
			
		||||
	if len(errs) > 0 {
 | 
			
		||||
		err = fmt.Errorf(strings.Join(errs, ", "))
 | 
			
		||||
		err = fmt.Errorf(strings.Join(errs, ", ")) // nolint: goerr113
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return metrics, ok, err
 | 
			
		||||
| 
						 | 
				
			
			@ -134,7 +135,7 @@ func (u *UnifiPoller) MetricsFrom(filter *Filter) (*Metrics, bool, error) {
 | 
			
		|||
	var err error
 | 
			
		||||
 | 
			
		||||
	if len(errs) > 0 {
 | 
			
		||||
		err = fmt.Errorf(strings.Join(errs, ", "))
 | 
			
		||||
		err = fmt.Errorf(strings.Join(errs, ", ")) // nolint: goerr113
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return metrics, ok, err
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,7 @@ import (
 | 
			
		|||
	"log"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Log the command that called these commands.
 | 
			
		||||
const callDepth = 2
 | 
			
		||||
 | 
			
		||||
// Logger is passed into input packages so they may write logs.
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +22,7 @@ func (u *UnifiPoller) Logf(m string, v ...interface{}) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// LogDebugf prints a debug log entry if debug is true and quite is false
 | 
			
		||||
// LogDebugf prints a debug log entry if debug is true and quite is false.
 | 
			
		||||
func (u *UnifiPoller) LogDebugf(m string, v ...interface{}) {
 | 
			
		||||
	if u.Debug && !u.Quiet {
 | 
			
		||||
		_ = log.Output(callDepth, fmt.Sprintf("[DEBUG] "+m, v...))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,8 +6,11 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	outputs    []*Output
 | 
			
		||||
	outputSync sync.Mutex
 | 
			
		||||
	// These are used to keep track of loaded output plugins.
 | 
			
		||||
	outputs             []*Output  // nolint: gochecknoglobals
 | 
			
		||||
	outputSync          sync.Mutex // nolint: gochecknoglobals
 | 
			
		||||
	errNoOutputPlugins  = fmt.Errorf("no output plugins imported")
 | 
			
		||||
	errAllOutputStopped = fmt.Errorf("all output plugins have stopped, or none enabled")
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Collect is passed into output packages so they may collect metrics to output.
 | 
			
		||||
| 
						 | 
				
			
			@ -55,7 +58,7 @@ func (u *UnifiPoller) InitializeOutputs() error {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	if count < 1 {
 | 
			
		||||
		return fmt.Errorf("no output plugins imported")
 | 
			
		||||
		return errNoOutputPlugins
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for err := range v {
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +67,7 @@ func (u *UnifiPoller) InitializeOutputs() error {
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		if count--; count == 0 {
 | 
			
		||||
			return fmt.Errorf("all output plugins have stopped, or none enabled")
 | 
			
		||||
			return errAllOutputStopped
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue