various: add golangci-lint, fix issues (#7905)

This adds an initial and intentionally minimal configuration for
golang-ci, fixes the issues reported, and adds a GitHub Action to check
new pull requests against this linter configuration.

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I8f38fbc315836a19a094d0d3e986758b9313f163
This commit is contained in:
Andrew Dunham
2023-04-17 18:38:24 -04:00
committed by GitHub
parent ff1b35ec6c
commit 280255acae
34 changed files with 529 additions and 269 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ func TestDNSOverTCP(t *testing.T) {
"bradfitz.ts.com.": "2.3.4.5",
}
for domain, _ := range wantResults {
for domain := range wantResults {
b := mkDNSRequest(domain, dns.TypeA, addEDNS)
binary.Write(c, binary.BigEndian, uint16(len(b)))
c.Write(b)
+1 -1
View File
@@ -502,7 +502,7 @@ func genRandomSubdomains(t *testing.T, n int) []dnsname.FQDN {
for len(domains) < cap(domains) {
l := r.Intn(19) + 1
b := make([]byte, l)
for i, _ := range b {
for i := range b {
b[i] = charset[r.Intn(len(charset))]
}
d := string(b) + ".example.com"
+1 -1
View File
@@ -224,7 +224,7 @@ func TestStateString(t *testing.T) {
},
},
InterfaceIPs: map[string][]netip.Prefix{
"eth0": []netip.Prefix{
"eth0": {
netip.MustParsePrefix("10.0.0.2/8"),
},
},
+1 -1
View File
@@ -961,7 +961,7 @@ var (
metricPMPSent = clientmetric.NewCounter("portmap_pmp_sent")
// metricPMPOK counts the number of times
// we received a succesful PMP response.
// we received a successful PMP response.
metricPMPOK = clientmetric.NewCounter("portmap_pmp_ok")
// metricPMPUnhandledOpcode counts the number of times
+1 -1
View File
@@ -346,7 +346,7 @@ func (d *Dialer) dialPeerAPI(ctx context.Context, network, addr string) (net.Con
//
// The primary function of this is to work on macOS & iOS's in the
// Network/System Extension so it can mark the dialer as staying
// withing the network namespace/sandbox.
// within the network namespace/sandbox.
func (d *Dialer) getPeerDialer() *net.Dialer {
d.peerDialerOnce.Do(func() {
d.peerDialer = &net.Dialer{