Pull request: all: fix lint and naming issues vol. 4

Merge in DNS/adguard-home from 2276-fix-lint-4 to master

Updates #2276.

Squashed commit of the following:

commit 15d49184cd8ce1f8701bf3221e69418ca1778b36
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Dec 8 15:51:34 2020 +0300

    util: fix naming

commit 3b9a86a0feb8c6e0b167e6e23105e8137b0dda76
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Dec 8 15:41:10 2020 +0300

    all: fix lint and naming issues vol. 4
This commit is contained in:
Ainar Garipov 2020-12-08 16:01:13 +03:00
parent b7bf7f78df
commit 73c30590e0
10 changed files with 12 additions and 23 deletions

View File

@ -65,3 +65,9 @@ func (e *manyError) Unwrap() error {
return e.underlying[0] return e.underlying[0]
} }
// wrapper is a copy of the hidden errors.wrapper interface for tests, linting,
// etc.
type wrapper interface {
Unwrap() error
}

View File

@ -41,6 +41,8 @@ func TestError_Error(t *testing.T) {
} }
func TestError_Unwrap(t *testing.T) { func TestError_Unwrap(t *testing.T) {
var _ wrapper = &manyError{}
const ( const (
errSimple = iota errSimple = iota
errWrapped errWrapped

View File

@ -129,8 +129,6 @@ const (
NotFilteredNotFound Reason = iota NotFilteredNotFound Reason = iota
// NotFilteredWhiteList - the host is explicitly whitelisted // NotFilteredWhiteList - the host is explicitly whitelisted
NotFilteredWhiteList NotFilteredWhiteList
// NotFilteredError - there was a transitive error during check
NotFilteredError
// reasons for filtering // reasons for filtering
@ -777,12 +775,3 @@ func (d *Dnsfilter) Start() {
d.registerBlockedServicesHandlers() d.registerBlockedServicesHandlers()
} }
} }
//
// stats
//
// GetStats return dns filtering stats since startup.
func (d *Dnsfilter) GetStats() Stats {
return gctx.stats
}

View File

@ -3,8 +3,9 @@
package sysutil package sysutil
import ( import (
"log"
"log/syslog" "log/syslog"
"github.com/AdguardTeam/golibs/log"
) )
func configureSyslog(serviceName string) error { func configureSyslog(serviceName string) error {

View File

@ -3,9 +3,9 @@
package sysutil package sysutil
import ( import (
"log"
"strings" "strings"
"github.com/AdguardTeam/golibs/log"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc/eventlog" "golang.org/x/sys/windows/svc/eventlog"
) )

View File

@ -9,7 +9,6 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path"
"runtime" "runtime"
"strings" "strings"
) )
@ -41,13 +40,6 @@ func RunCommand(command string, arguments ...string) (int, string, error) {
return cmd.ProcessState.ExitCode(), string(out), nil return cmd.ProcessState.ExitCode(), string(out), nil
} }
func FuncName() string {
pc := make([]uintptr, 10) // at least 1 entry needed
runtime.Callers(2, pc)
f := runtime.FuncForPC(pc[0])
return path.Base(f.Name())
}
// SplitNext - split string by a byte and return the first chunk // SplitNext - split string by a byte and return the first chunk
// Skip empty chunks // Skip empty chunks
// Whitespace is trimmed // Whitespace is trimmed

View File

@ -1,7 +1,6 @@
package util package util
import ( import (
"log"
"testing" "testing"
) )
@ -19,6 +18,6 @@ func TestGetValidNetInterfacesForWeb(t *testing.T) {
t.Fatalf("No addresses found for %s", iface.Name) t.Fatalf("No addresses found for %s", iface.Name)
} }
log.Printf("%v", iface) t.Logf("%v", iface)
} }
} }