Browse Source

golangci-lint fixes

master
Isaac 2 years ago
parent
commit
7df98da758
  1. 8
      autocert.go
  2. 12
      autocert_test.go

8
autocert.go

@ -107,7 +107,7 @@ func (m *AutoCert) HTTPHandler(handler http.Handler) http.Handler {
return
}
w.Write(keyAuth)
_, _ = w.Write(keyAuth)
})
}
@ -198,7 +198,7 @@ func (m *AutoCert) putCache(data []byte, keys ...string) context.Context {
}
go func() {
ioutil.WriteFile(path.Join(m.CacheDir, key), data, 0700)
_ = ioutil.WriteFile(path.Join(m.CacheDir, key), data, 0700)
cancel()
}()
@ -415,14 +415,14 @@ func (m *AutoCert) issueCert(domainName string) (*tls.Certificate, error) {
}
certPem := certKeyPem
var certDer [][]byte
// var certDer [][]byte
for _, c := range certs {
b := pem.EncodeToMemory(&pem.Block{
Type: "CERTIFICATE",
Bytes: c.Raw,
})
certPem = append(certPem, b...)
certDer = append(certDer, c.Raw)
// certDer = append(certDer, c.Raw)
}
m.putCache(certPem, "cert", domainName)

12
autocert_test.go

@ -79,16 +79,16 @@ func TestAutoCert_GetCertificate(t *testing.T) {
},
}
for _, test := range tests {
_, err := test.ac.GetCertificate(test.helo)
if test.err && err == nil {
for k := range tests {
_, err := tests[k].ac.GetCertificate(tests[k].helo)
if tests[k].err && err == nil {
t.Fatalf("expected error, got none")
}
if !test.err && err != nil {
if !tests[k].err && err != nil {
t.Fatalf("expected no error, got: %v", err)
}
if !strings.Contains(err.Error(), test.errStr) {
t.Fatalf("missing %q in error: %v", test.errStr, err)
if !strings.Contains(err.Error(), tests[k].errStr) {
t.Fatalf("missing %q in error: %v", tests[k].errStr, err)
}
}

Loading…
Cancel
Save