From 12a0d308c92a9dfb5248377a508c2eb35fbad797 Mon Sep 17 00:00:00 2001 From: Matthias Fasching Date: Thu, 5 May 2022 12:44:12 +0000 Subject: [PATCH] Fix various issues that golint complains about --- default_context_test.go | 10 +++++----- home.go | 2 +- mail/internal/mail/mime.go | 3 --- mail/internal/mail/mime_go14.go | 25 ------------------------- plugins/log.go | 2 +- plugins/log_debug.go | 2 +- plugins/plugdeps/plugdeps.go | 8 ++++---- plugins/plugdeps/plugins.go | 2 +- server_test.go | 14 +++++++------- 9 files changed, 20 insertions(+), 48 deletions(-) delete mode 100644 mail/internal/mail/mime_go14.go diff --git a/default_context_test.go b/default_context_test.go index 203781641..bf8c56463 100644 --- a/default_context_test.go +++ b/default_context_test.go @@ -143,7 +143,7 @@ func Test_DefaultContext_GetSet(t *testing.T) { r.Equal("Mark", c.Value("name").(string)) } -func Test_DefaultContext_Set_Unconfigured(t *testing.T) { +func Test_DefaultContext_Set_not_configured(t *testing.T) { r := require.New(t) c := DefaultContext{} @@ -162,7 +162,7 @@ func Test_DefaultContext_Value(t *testing.T) { r.Equal("Mark", c.Value("name").(string)) } -func Test_DefaultContext_Value_Unconfigured(t *testing.T) { +func Test_DefaultContext_Value_not_configured(t *testing.T) { r := require.New(t) c := DefaultContext{} r.Nil(c.Value("name")) @@ -323,7 +323,7 @@ func Test_DefaultContext_Data(t *testing.T) { r.EqualValues(map[string]interface{}{}, c.Data()) } -func Test_DefaultContext_Data_Unconfigured(t *testing.T) { +func Test_DefaultContext_Data_not_configured(t *testing.T) { r := require.New(t) c := DefaultContext{} @@ -345,7 +345,7 @@ func Test_DefaultContext_String_EmptyData(t *testing.T) { r.EqualValues("", c.String()) } -func Test_DefaultContext_String_EmptyData_Unconfigured(t *testing.T) { +func Test_DefaultContext_String_EmptyData_not_configured(t *testing.T) { r := require.New(t) c := DefaultContext{} @@ -372,7 +372,7 @@ func Test_DefaultContext_MarshalJSON_EmptyData(t *testing.T) { r.EqualValues(`{}`, string(jb)) } -func Test_DefaultContext_MarshalJSON_EmptyData_Unconfigured(t *testing.T) { +func Test_DefaultContext_MarshalJSON_EmptyData_not_configured(t *testing.T) { r := require.New(t) c := DefaultContext{} diff --git a/home.go b/home.go index 79255e547..83c3d9043 100644 --- a/home.go +++ b/home.go @@ -14,7 +14,7 @@ import ( could be strage. */ -// Home is a container for Domains and Groups that independantly serves a +// Home is a container for Domains and Groups that independently serves a // group of pages with its own Middleware and ErrorHandlers. It is usually // a multi-homed server domain or group of paths under a certain prefix. // diff --git a/mail/internal/mail/mime.go b/mail/internal/mail/mime.go index 580ac2c3e..61e259402 100644 --- a/mail/internal/mail/mime.go +++ b/mail/internal/mail/mime.go @@ -1,6 +1,3 @@ -//go:build go1.5 -// +build go1.5 - package mail import ( diff --git a/mail/internal/mail/mime_go14.go b/mail/internal/mail/mime_go14.go deleted file mode 100644 index bdb605dcc..000000000 --- a/mail/internal/mail/mime_go14.go +++ /dev/null @@ -1,25 +0,0 @@ -// +build !go1.5 - -package mail - -import "gopkg.in/alexcesaro/quotedprintable.v3" - -var newQPWriter = quotedprintable.NewWriter - -type mimeEncoder struct { - quotedprintable.WordEncoder -} - -var ( - bEncoding = mimeEncoder{quotedprintable.BEncoding} - qEncoding = mimeEncoder{quotedprintable.QEncoding} - lastIndexByte = func(s string, c byte) int { - for i := len(s) - 1; i >= 0; i-- { - - if s[i] == c { - return i - } - } - return -1 - } -) diff --git a/plugins/log.go b/plugins/log.go index 8a8909763..1512e826f 100644 --- a/plugins/log.go +++ b/plugins/log.go @@ -1,4 +1,4 @@ -//+build !debug +// +build !debug package plugins diff --git a/plugins/log_debug.go b/plugins/log_debug.go index 8c6fcae03..97457c0b6 100644 --- a/plugins/log_debug.go +++ b/plugins/log_debug.go @@ -1,4 +1,4 @@ -//+build debug +// +build debug package plugins diff --git a/plugins/plugdeps/plugdeps.go b/plugins/plugdeps/plugdeps.go index b80e4f3a2..a3c59d44f 100644 --- a/plugins/plugdeps/plugdeps.go +++ b/plugins/plugdeps/plugdeps.go @@ -13,7 +13,7 @@ import ( // ErrMissingConfig is if config/buffalo-plugins.toml file is not found. Use plugdeps#On(app) to test if plugdeps are being used var ErrMissingConfig = fmt.Errorf("could not find a buffalo-plugins config file at %s", ConfigPath(meta.New("."))) -// List all of the plugins the application depeneds on. Will return ErrMissingConfig +// List all of the plugins the application depends on. Will return ErrMissingConfig // if the app is not using config/buffalo-plugins.toml to manage their plugins. // Use plugdeps#On(app) to test if plugdeps are being used. func List(app meta.App) (*Plugins, error) { @@ -46,11 +46,11 @@ func List(app meta.App) (*Plugins, error) { func listLocal(app meta.App) (*Plugins, error) { plugs := New() - proot := filepath.Join(app.Root, "plugins") - if _, err := os.Stat(proot); err != nil { + pRoot := filepath.Join(app.Root, "plugins") + if _, err := os.Stat(pRoot); err != nil { return plugs, nil } - err := filepath.WalkDir(proot, func(path string, d fs.DirEntry, err error) error { + err := filepath.WalkDir(pRoot, func(path string, d fs.DirEntry, err error) error { if d.IsDir() { return nil } diff --git a/plugins/plugdeps/plugins.go b/plugins/plugdeps/plugins.go index 4f3266051..3a9d9ab0d 100644 --- a/plugins/plugdeps/plugins.go +++ b/plugins/plugdeps/plugins.go @@ -32,7 +32,7 @@ func (plugs *Plugins) Decode(r io.Reader) error { tp := &tomlPlugins{ Plugins: []Plugin{}, } - if _, err := toml.DecodeReader(r, tp); err != nil { + if _, err := toml.NewDecoder(r).Decode(tp); err != nil { return err } for _, p := range tp.Plugins { diff --git a/server_test.go b/server_test.go index 1e8f148b9..9ff9b6384 100644 --- a/server_test.go +++ b/server_test.go @@ -16,9 +16,9 @@ import ( // timing sensitive. Adjust this timing values if they are failing due to // timing issue. const ( - WAIT_START = 2 - WAIT_RUN = 2 - CONSUMER_RUN = 8 + waitStart = 2 + waitRun = 2 + consumerRun = 8 ) // startApp starts given buffalo app and check its exit status. @@ -32,7 +32,7 @@ func startApp(app *App, wg *sync.WaitGroup, r *require.Assertions) { }() // wait until the server started. // could be improved with connection test but that's too much... - time.Sleep(WAIT_START * time.Second) + time.Sleep(waitStart * time.Second) } func Test_Server_Simple(t *testing.T) { @@ -55,7 +55,7 @@ var handlerDone = false // timeConsumer consumes about 10 minutes for processing its request func timeConsumer(c Context) error { - for i := 0; i < CONSUMER_RUN; i++ { + for i := 0; i < consumerRun; i++ { fmt.Println("#") time.Sleep(1 * time.Second) } @@ -89,7 +89,7 @@ func Test_Server_GracefulShutdownOngoingRequest(t *testing.T) { firstQuery = true }() // make sure the request sent - time.Sleep(WAIT_RUN * time.Second) + time.Sleep(waitRun * time.Second) app.cancel() time.Sleep(1 * time.Second) // make sure the server started shutdown. @@ -114,7 +114,7 @@ func Test_Server_GracefulShutdownOngoingRequest(t *testing.T) { var timerDone = false func timerWorker(args worker.Args) error { - for i := 0; i < CONSUMER_RUN; i++ { + for i := 0; i < consumerRun; i++ { fmt.Println("%") time.Sleep(1 * time.Second) }