lint: new warnings from 1.21 golang-lint

This commit is contained in:
Umputun
2019-10-31 22:09:28 -05:00
parent ecb804ce41
commit cdcf5171cf
6 changed files with 23 additions and 19 deletions
+3 -2
View File
@@ -17,8 +17,9 @@ import (
// ImportCommand set of flags and command for import
type ImportCommand struct {
InputFile string `short:"f" long:"file" description:"input file name" required:"true"`
Provider string `short:"p" long:"provider" default:"disqus" choice:"disqus" choice:"wordpress" description:"import format"`
InputFile string `short:"f" long:"file" description:"input file name" required:"true"`
Provider string `short:"p" long:"provider" default:"disqus" choice:"disqus" choice:"wordpress" description
:"import format"` // nolint
Site string `short:"s" long:"site" env:"SITE" default:"remark" description:"site name"`
Timeout time.Duration `long:"timeout" default:"15m" description:"import timeout"`
AdminPasswd string `long:"admin-passwd" env:"ADMIN_PASSWD" required:"true" description:"admin basic auth password"`
+2 -2
View File
@@ -108,7 +108,7 @@ type AuthGroup struct {
// StoreGroup defines options group for store params
type StoreGroup struct {
Type string `long:"type" env:"TYPE" description:"type of storage" choice:"bolt" choice:"rpc" default:"bolt"`
Type string `long:"type" env:"TYPE" description:"type of storage" choice:"bolt" choice:"rpc" default:"bolt"` // nolint
Bolt struct {
Path string `long:"path" env:"PATH" default:"./var" description:"parent dir for bolt files"`
Timeout time.Duration `long:"timeout" env:"TIMEOUT" default:"30s" description:"bolt timeout"`
@@ -118,7 +118,7 @@ type StoreGroup struct {
// ImageGroup defines options group for store pictures
type ImageGroup struct {
Type string `long:"type" env:"TYPE" description:"type of storage" choice:"fs" choice:"bolt" default:"fs"`
Type string `long:"type" env:"TYPE" description:"type of storage" choice:"fs" choice:"bolt" default:"fs"` // nolint
FS struct {
Path string `long:"path" env:"PATH" default:"./var/pictures" description:"images location"`
Staging string `long:"staging" env:"STAGING" default:"./var/pictures.staging" description:"staging location"`
+1
View File
@@ -49,6 +49,7 @@ func TestServerApp(t *testing.T) {
req.SetBasicAuth("admin", "password")
resp, err = client.Do(req)
require.Nil(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusCreated, resp.StatusCode)
body, _ = ioutil.ReadAll(resp.Body)
t.Log(string(body))
+4 -2
View File
@@ -47,7 +47,8 @@ func TestAdmin_Delete(t *testing.T) {
// check multi count
resp, err := post(t, ts.URL+"/api/v1/counts?site=remark42", `["https://radio-t.com/blah","https://radio-t.com/blah2"]`)
assert.Nil(t, err)
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusOK, resp.StatusCode)
bb, err := ioutil.ReadAll(resp.Body)
assert.Nil(t, err)
@@ -60,7 +61,8 @@ func TestAdmin_Delete(t *testing.T) {
// delete a comment
req, err := http.NewRequest(http.MethodDelete,
fmt.Sprintf("%s/api/v1/admin/comment/%s?site=remark42&url=https://radio-t.com/blah", ts.URL, id1), nil)
assert.Nil(t, err)
require.NoError(t, err)
defer resp.Body.Close()
requireAdminOnly(t, req)
resp, err = sendReq(t, req, adminUmputunToken)
assert.Nil(t, err)
+12 -12
View File
@@ -174,32 +174,32 @@ func (m *Migrator) remapCtrl(w http.ResponseWriter, r *http.Request) {
defer m.setBusy(siteID, false)
// do export
fh, err := ioutil.TempFile("", "remark42_convert")
if err != nil {
log.Printf("[WARN] failed to make temp file %+v", err)
fh, e := ioutil.TempFile("", "remark42_convert")
if e != nil {
log.Printf("[WARN] failed to make temp file %+v", e)
return
}
defer func() {
if err := os.Remove(fh.Name()); err != nil {
log.Printf("[WARN] failed to remove temp file %+v", err)
if e := os.Remove(fh.Name()); e != nil {
log.Printf("[WARN] failed to remove temp file %+v", e)
}
}()
log.Printf("[DEBUG] start export for site=%s", siteID)
if _, err := m.NativeExporter.Export(fh, siteID); err != nil {
log.Printf("[WARN] export failed with %+v", err)
if _, e := m.NativeExporter.Export(fh, siteID); e != nil {
log.Printf("[WARN] export failed with %+v", e)
return
}
if _, err = fh.Seek(0, 0); err != nil {
log.Printf("[WARN] failed to seek file %+v", err)
if _, e = fh.Seek(0, 0); e != nil {
log.Printf("[WARN] failed to seek file %+v", e)
return
}
log.Printf("[DEBUG] start import for site=%s", siteID)
mappedReader := migrator.WithMapper(fh, mapper)
size, err := m.NativeImporter.Import(mappedReader, siteID)
if err != nil {
log.Printf("[WARN] import failed with %+v", err)
size, e := m.NativeImporter.Import(mappedReader, siteID)
if e != nil {
log.Printf("[WARN] import failed with %+v", e)
return
}
+1 -1
View File
@@ -119,7 +119,7 @@ func (s *Rest) makeTLSConfig() *tls.Config {
// tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
// tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
},
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{