diff --git a/.gometalinter.json b/.gometalinter.json new file mode 100644 index 000000000..e4f65a36e --- /dev/null +++ b/.gometalinter.json @@ -0,0 +1,3 @@ +{ + "Enable": ["vet", "golint", "goimports", "deadcode", "gotype", "ineffassign", "misspell", "nakedret", "unconvert", "megacheck", "varcheck"] +} diff --git a/Dockerfile b/Dockerfile index ca2dfbfcb..332098b96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,8 @@ FROM gobuffalo/buffalo:development RUN buffalo version -RUN go get -v -u github.com/golang/lint/golint +RUN go get -u github.com/alecthomas/gometalinter +RUN gometalinter --install RUN go get -v -u github.com/markbates/filetest RUN go get -v -u github.com/gobuffalo/makr RUN go get -v -u github.com/markbates/grift @@ -24,10 +25,9 @@ RUN go get -v -t ./... RUN go install -v -tags sqlite ./buffalo -RUN go test -tags sqlite -race $(go list ./... | grep -v /vendor/) - -RUN golint -set_exit_status $(go list ./... | grep -v /vendor/) +RUN go test -tags sqlite -race ./... +RUN gometalinter --vendor --deadline=5m ./... WORKDIR $GOPATH/src/ RUN buffalo new --db-type=sqlite3 hello_world --ci-provider=travis @@ -35,7 +35,7 @@ WORKDIR ./hello_world RUN filetest -c $GOPATH/src/github.com/gobuffalo/buffalo/buffalo/cmd/filetests/new_travis.json -RUN go vet -x $(go list ./... | grep -v /vendor/) +RUN go vet ./... RUN buffalo db create -a RUN buffalo db migrate -e test RUN buffalo test -race diff --git a/app.go b/app.go index 09334a270..9386b590b 100644 --- a/app.go +++ b/app.go @@ -49,22 +49,19 @@ func (a *App) Serve() error { <-ctx.Done() logrus.Info("Shutting down application") - err := a.Stop(ctx.Err()) - if err != nil { + if err := a.Stop(ctx.Err()); err != nil { logrus.Error(err) } if !a.WorkerOff { // stop the workers logrus.Info("Shutting down worker") - err = a.Worker.Stop() - if err != nil { + if err := a.Worker.Stop(); err != nil { logrus.Error(err) } } - err = server.Shutdown(ctx) - if err != nil { + if err := server.Shutdown(ctx); err != nil { logrus.Error(err) } @@ -73,15 +70,12 @@ func (a *App) Serve() error { // if configured to do so, start the workers if !a.WorkerOff { go func() { - err := a.Worker.Start(ctx) - if err != nil { + if err := a.Worker.Start(ctx); err != nil { a.Stop(err) } }() } - var err error - if strings.HasPrefix(a.Options.Addr, "unix:") { // Use an UNIX socket listener, err := net.Listen("unix", a.Options.Addr[5:]) @@ -89,16 +83,16 @@ func (a *App) Serve() error { return a.Stop(err) } // start the web server - err = server.Serve(listener) - } else { - // Use a TCP socket - server.Addr = a.Options.Addr - - // start the web server - err = server.ListenAndServe() + if err = server.Serve(listener); err != nil { + return a.Stop(err) + } + return nil } + // Use a TCP socket + server.Addr = a.Options.Addr - if err != nil { + // start the web server + if err := server.ListenAndServe(); err != nil { return a.Stop(err) } @@ -126,8 +120,7 @@ func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - var h http.Handler - h = a.router + var h http.Handler = a.router if a.Env == "development" { h = web.ErrorChecker(h) } @@ -160,8 +153,8 @@ func New(opts Options) *App { } } - a.router.NotFoundHandler = http.HandlerFunc(notFoundHandler("path not found: %s %s", 404)) - a.router.MethodNotAllowedHandler = http.HandlerFunc(notFoundHandler("method not found: %s %s", 405)) + a.router.NotFoundHandler = notFoundHandler("path not found: %s %s", 404) + a.router.MethodNotAllowedHandler = notFoundHandler("method not found: %s %s", 405) if a.MethodOverride == nil { a.MethodOverride = MethodOverride diff --git a/binding/file.go b/binding/file.go index 91dece63b..6fe694af1 100644 --- a/binding/file.go +++ b/binding/file.go @@ -22,10 +22,7 @@ type File struct { // Valid if there is an actual uploaded file func (f File) Valid() bool { - if f.File == nil { - return false - } - return true + return f.File != nil } func (f File) String() string { diff --git a/binding/file_test.go b/binding/file_test.go index 22c13191d..4cefe1461 100644 --- a/binding/file_test.go +++ b/binding/file_test.go @@ -106,10 +106,11 @@ func newfileUploadRequest(uri string, paramName, path string) (*http.Request, er if err != nil { return nil, err } - _, err = io.Copy(part, file) + if _, err = io.Copy(part, file); err != nil { + return nil, err + } - err = writer.Close() - if err != nil { + if err = writer.Close(); err != nil { return nil, err } diff --git a/buffalo/cmd/build/templates.go b/buffalo/cmd/build/templates.go index 7524a6379..9ff03e877 100644 --- a/buffalo/cmd/build/templates.go +++ b/buffalo/cmd/build/templates.go @@ -19,7 +19,7 @@ func (b *Builder) validateTemplates() error { return nil } errs := []string{} - err := filepath.Walk(filepath.Join(b.App.Root, "templates"), func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(filepath.Join(b.App.Root, "templates"), func(path string, info os.FileInfo, _ error) error { if info == nil || info.IsDir() { return nil } diff --git a/buffalo/cmd/destroy/resource.go b/buffalo/cmd/destroy/resource.go index c341c1cf3..f32d20d91 100644 --- a/buffalo/cmd/destroy/resource.go +++ b/buffalo/cmd/destroy/resource.go @@ -47,7 +47,7 @@ var ResourceCmd = &cobra.Command{ func confirm(msg string) bool { reader := bufio.NewReader(os.Stdin) - fmt.Printf(msg) + fmt.Print(msg) text, _ := reader.ReadString('\n') return (text == "y\n" || text == "Y\n") @@ -55,7 +55,7 @@ func confirm(msg string) bool { func removeTemplates(fileName string) { if YesToAll || confirm("Want to remove templates? (Y/n)") { - templatesFolder := fmt.Sprintf(filepath.Join("templates", fileName)) + templatesFolder := filepath.Join("templates", fileName) logrus.Infof("- Deleted %v folder\n", templatesFolder) os.RemoveAll(templatesFolder) } diff --git a/buffalo/cmd/dev.go b/buffalo/cmd/dev.go index 119acdac4..04be5cad6 100644 --- a/buffalo/cmd/dev.go +++ b/buffalo/cmd/dev.go @@ -101,15 +101,16 @@ func startWebpack(ctx context.Context) error { func startDevServer(ctx context.Context) error { cfgFile := "./.buffalo.dev.yml" - _, err := os.Stat(cfgFile) - if err != nil { + if _, err := os.Stat(cfgFile); err != nil { err = rg.Run("./", map[string]interface{}{ "name": "buffalo", }) + if err != nil { + return err + } } c := &refresh.Configuration{} - err = c.Load(cfgFile) - if err != nil { + if err := c.Load(cfgFile); err != nil { return err } c.Debug = devOptions.Debug diff --git a/buffalo/cmd/generate/resource.go b/buffalo/cmd/generate/resource.go index 5ba2c372a..07a18e433 100644 --- a/buffalo/cmd/generate/resource.go +++ b/buffalo/cmd/generate/resource.go @@ -44,8 +44,6 @@ var ResourceCmd = &cobra.Command{ }, } -var resourceMN string - func init() { ResourceCmd.Flags().BoolVarP(&resourceOptions.SkipMigration, "skip-migration", "s", false, "tells resource generator not-to add model migration") ResourceCmd.Flags().BoolVarP(&resourceOptions.SkipModel, "skip-model", "", false, "tells resource generator not to generate model nor migrations") diff --git a/buffalo/cmd/new.go b/buffalo/cmd/new.go index 10a04fe53..074ead63d 100644 --- a/buffalo/cmd/new.go +++ b/buffalo/cmd/new.go @@ -22,8 +22,6 @@ import ( "github.com/spf13/cobra" ) -var rootPath string - var app = newapp.Generator{ App: meta.New("."), DBType: "postgres", diff --git a/buffalo/cmd/root.go b/buffalo/cmd/root.go index 7727ad816..82130c608 100644 --- a/buffalo/cmd/root.go +++ b/buffalo/cmd/root.go @@ -29,7 +29,7 @@ var RootCmd = &cobra.Command{ return nil } - if insideBuffaloProject() == false { + if !insideBuffaloProject() { return errors.New("you need to be inside your buffalo project path to run this command") } diff --git a/buffalo/cmd/setup.go b/buffalo/cmd/setup.go index ca7e9ce5b..16de205b8 100644 --- a/buffalo/cmd/setup.go +++ b/buffalo/cmd/setup.go @@ -57,7 +57,6 @@ Tests: } func updateGoDepsCheck(app meta.App) error { - deps, _ := deplist.List() if app.WithDep { // use github.com/golang/dep args := []string{"ensure"} @@ -189,8 +188,7 @@ func npmCheck(app meta.App) error { } func yarnCheck(app meta.App) error { - err := nodeCheck(app) - if err != nil { + if err := nodeCheck(app); err != nil { return errors.WithStack(err) } if _, err := exec.LookPath("yarn"); err != nil { @@ -199,8 +197,7 @@ func yarnCheck(app meta.App) error { return errors.Errorf("This application require yarn, and we could not find it installed on your system. We tried to install it for you, but ran into the following error:\n%s", err) } } - err = run(exec.Command("yarn", "install", "--no-progress")) - if err != nil { + if err := run(exec.Command("yarn", "install", "--no-progress")); err != nil { return errors.Errorf("We encountered the following error when trying to install your asset dependencies using yarn:\n%s", err) } return nil diff --git a/buffalo/cmd/updater/dep.go b/buffalo/cmd/updater/dep.go index a542b49e4..bf230e01e 100644 --- a/buffalo/cmd/updater/dep.go +++ b/buffalo/cmd/updater/dep.go @@ -12,14 +12,6 @@ import ( "golang.org/x/sync/errgroup" ) -type lockToml struct { - Name string `toml:"name"` - Branch string `toml:"branch"` - Packages []string `toml:"packages"` - Revision string `toml:"revision"` - Version string `toml:"version"` -} - func goGetUpdate(r *Runner) error { fmt.Println("~~~ Running go get ~~~") ctx, cancel := context.WithCancel(context.Background()) @@ -68,10 +60,8 @@ func DepEnsure(r *Runner) error { "github.com/gobuffalo/suite@v2.0.0", } args := []string{"ensure", "-v", "-add"} + args = append(args, apkg...) - for _, p := range apkg { - args = append(args, p) - } cc = exec.Command("dep", args...) cc.Stdin = os.Stdin cc.Stderr = os.Stderr @@ -87,9 +77,7 @@ func DepEnsure(r *Runner) error { } args = []string{"ensure", "-v", "-update"} - for _, p := range upkg { - args = append(args, p) - } + args = append(args, upkg...) cc = exec.Command("dep", args...) cc.Stdin = os.Stdin cc.Stderr = os.Stderr diff --git a/buffalo/cmd/updater/deprecations.go b/buffalo/cmd/updater/deprecations.go index 28a2b2684..e59c0bf8a 100644 --- a/buffalo/cmd/updater/deprecations.go +++ b/buffalo/cmd/updater/deprecations.go @@ -21,7 +21,7 @@ func DeprecrationsCheck(r *Runner) error { r.Warnings = append(r.Warnings, "app.Start has been removed in v0.11.0. Use app.Serve Instead. [main.go]") } - return filepath.Walk(filepath.Join(r.App.Root, "actions"), func(path string, info os.FileInfo, err error) error { + return filepath.Walk(filepath.Join(r.App.Root, "actions"), func(path string, info os.FileInfo, _ error) error { if info.IsDir() { return nil } @@ -47,7 +47,7 @@ func DeprecrationsCheck(r *Runner) error { if bytes.Contains(b, []byte("T.LanguageFinder=")) || bytes.Contains(b, []byte("T.LanguageFinder ")) { r.Warnings = append(r.Warnings, fmt.Sprintf("i18n.Translator#LanguageFinder has been deprecated in v0.11.1. Use i18n.Translator#LanguageExtractors instead. [%s]", path)) } - ioutil.WriteFile(path, b, 664) + ioutil.WriteFile(path, b, 0664) return nil }) diff --git a/buffalo/cmd/updater/imports.go b/buffalo/cmd/updater/imports.go index 1213a6ad5..c1c6fecdf 100644 --- a/buffalo/cmd/updater/imports.go +++ b/buffalo/cmd/updater/imports.go @@ -125,7 +125,7 @@ func (c ImportConverter) rewriteFile(name string) error { } } - // if no change occured, then we don't need to write to disk, just return. + // if no change occurred, then we don't need to write to disk, just return. if !change { return nil } diff --git a/default_context.go b/default_context.go index 5b13fceeb..d170ef610 100644 --- a/default_context.go +++ b/default_context.go @@ -178,10 +178,10 @@ func (d *DefaultContext) Error(status int, err error) error { // Websocket is deprecated, and will be removed in v0.12.0. Use github.com/gorilla/websocket directly instead. func (d *DefaultContext) Websocket() (*websocket.Conn, error) { warningMsg := "Websocket is deprecated, and will be removed in v0.12.0. Use github.com/gorilla/websocket directly instead." - _, file, no, ok := runtime.Caller(1) - if ok { + if _, file, no, ok := runtime.Caller(1); ok { warningMsg = fmt.Sprintf("%s Called from %s:%d", warningMsg, file, no) } + fmt.Println(warningMsg) return defaultUpgrader.Upgrade(d.Response(), d.Request(), nil) } diff --git a/errors.go b/errors.go index a3d52f884..5b3bca44f 100644 --- a/errors.go +++ b/errors.go @@ -80,10 +80,10 @@ func productionErrorResponseFor(status int) []byte { return []byte(prodErrorTmpl) } -func defaultErrorHandler(status int, err error, c Context) error { +func defaultErrorHandler(status int, origErr error, c Context) error { env := c.Value("env") - c.Logger().Error(err) + c.Logger().Error(origErr) c.Response().WriteHeader(status) if env != nil && env.(string) == "production" { @@ -92,17 +92,22 @@ func defaultErrorHandler(status int, err error, c Context) error { return nil } - msg := fmt.Sprintf("%+v", err) + msg := fmt.Sprintf("%+v", origErr) ct := httpx.ContentType(c.Request()) switch strings.ToLower(ct) { case "application/json", "text/json", "json": - err = json.NewEncoder(c.Response()).Encode(map[string]interface{}{ + err := json.NewEncoder(c.Response()).Encode(map[string]interface{}{ "error": msg, "code": status, }) + if err != nil { + return errors.WithStack(err) + } case "application/xml", "text/xml", "xml": default: - err := c.Request().ParseForm() + if err := c.Request().ParseForm(); err != nil { + msg = fmt.Sprintf("%s\n%s", err.Error(), msg) + } routes := c.Value("routes") if cd, ok := c.(*DefaultContext); ok { delete(cd.data, "app") @@ -130,7 +135,7 @@ func defaultErrorHandler(status int, err error, c Context) error { _, err = res.Write([]byte(t)) return err } - return err + return nil } type inspectHeaders http.Header diff --git a/generators/action/action.go b/generators/action/action.go index 72637234b..0b826e2bf 100644 --- a/generators/action/action.go +++ b/generators/action/action.go @@ -77,7 +77,7 @@ func (act Generator) buildTestsTemplate(filePath string) string { func (act Generator) addTemplateFiles(actionsToAdd []inflect.Name, data makr.Data) error { for _, action := range actionsToAdd { vg := makr.New() - viewPath := filepath.Join("templates", fmt.Sprintf("%s", act.Name.File()), fmt.Sprintf("%s.html", action.File())) + viewPath := filepath.Join("templates", act.Name.File(), fmt.Sprintf("%s.html", action.File())) vg.Add(makr.NewFile(viewPath, viewTmpl)) err := vg.Run(".", makr.Data{ "opts": act, diff --git a/generators/grift/generator.go b/generators/grift/generator.go index af1525dcd..521c4679b 100644 --- a/generators/grift/generator.go +++ b/generators/grift/generator.go @@ -35,7 +35,7 @@ func New(args ...string) (Generator, error) { for _, n := range strings.Split(args[0], ":") { g.Parts = append(g.Parts, inflect.Name(n)) } - g.Name = inflect.Name(g.Parts[len(g.Parts)-1]) + g.Name = g.Parts[len(g.Parts)-1] } return g, g.Validate() diff --git a/generators/newapp/generator.go b/generators/newapp/generator.go index 50cf1104a..5271611f0 100644 --- a/generators/newapp/generator.go +++ b/generators/newapp/generator.go @@ -106,4 +106,4 @@ func (g Generator) validateInGoPath() error { } var forbiddenAppNames = []string{"buffalo"} -var nameRX = regexp.MustCompile("^[\\w-]+$") +var nameRX = regexp.MustCompile(`^[\w-]+$`) diff --git a/grifts/tools.go b/grifts/tools.go new file mode 100644 index 000000000..0f43f9bf3 --- /dev/null +++ b/grifts/tools.go @@ -0,0 +1,40 @@ +package grifts + +import ( + "os" + "os/exec" + + "github.com/markbates/grift/grift" + "github.com/pkg/errors" +) + +var _ = grift.Namespace("tools", func() { + + var run = func(args ...string) error { + cmd := exec.Command(args[0], args[1:]...) + cmd.Stdin = os.Stdin + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + return cmd.Run() + } + + var _ = grift.Add("install", func(c *grift.Context) error { + if _, err := exec.LookPath("gometalinter"); err != nil { + if err := run("go", "get", "-u", "-v", "github.com/alecthomas/gometalinter"); err != nil { + return errors.WithStack(err) + } + if err := run("gometalinter", "--install"); err != nil { + return errors.WithStack(err) + } + } + return nil + }) + + var _ = grift.Add("lint", func(c *grift.Context) error { + if err := grift.Run("tools:install", c); err != nil { + return err + } + return run("gometalinter", "--vendor", "--deadline=3m", "./...") + }) + +}) diff --git a/logger_formatter.go b/logger_formatter.go index 6fde57e1b..03c2aba52 100644 --- a/logger_formatter.go +++ b/logger_formatter.go @@ -18,12 +18,10 @@ import ( ) const ( - nocolor = 0 - red = 31 - green = 32 - yellow = 33 - blue = 36 - gray = 37 + red = 31 + yellow = 33 + blue = 36 + gray = 37 ) // textFormatter formats logs into text diff --git a/mail/message.go b/mail/message.go index fd807cca5..89f5d1719 100644 --- a/mail/message.go +++ b/mail/message.go @@ -46,7 +46,7 @@ func (m *Message) AddBody(r render.Renderer, data render.Data) error { } m.Bodies = append(m.Bodies, Body{ - Content: string(buf.Bytes()), + Content: buf.String(), ContentType: r.ContentType(), }) diff --git a/mail/smtp_sender.go b/mail/smtp_sender.go index 1a55e550b..3a17cc191 100644 --- a/mail/smtp_sender.go +++ b/mail/smtp_sender.go @@ -56,11 +56,8 @@ func (sm SMTPSender) addBodies(message Message, gm *gomail.Message) { func (sm SMTPSender) addAttachments(message Message, gm *gomail.Message) { for _, at := range message.Attachments { settings := gomail.SetCopyFunc(func(w io.Writer) error { - if _, err := io.Copy(w, at.Reader); err != nil { - return err - } - - return nil + _, err := io.Copy(w, at.Reader) + return err }) gm.Attach(at.Name, settings) diff --git a/meta/app.go b/meta/app.go index b3ab159d7..d68893037 100644 --- a/meta/app.go +++ b/meta/app.go @@ -43,7 +43,7 @@ func New(root string) App { pwd = ResolveSymlinks(pwd) os.Chdir(pwd) if runtime.GOOS != "windows" { - // On Non-Windows OS, os.Getwd() uses PWD env var as a prefered + // On Non-Windows OS, os.Getwd() uses PWD env var as a preferred // way to get the working dir. os.Setenv("PWD", pwd) } @@ -56,7 +56,7 @@ func New(root string) App { }() // Gather meta data - name := Name(filepath.Base(root)) + name := inflect.Name(filepath.Base(root)) pp := envy.CurrentPackage() if filepath.Base(pp) != string(name) { pp = path.Join(pp, string(name)) diff --git a/meta/name.go b/meta/name.go index fc678b085..4f23f8df9 100644 --- a/meta/name.go +++ b/meta/name.go @@ -10,9 +10,9 @@ import ( // Name is deprecated, please use github.com/markbates/inflect.Name instead. func Name(s string) inflect.Name { warningMsg := "Name is deprecated, and will be removed in v0.12.0. Use github.com/markbates/inflect.Name instead." - _, file, no, ok := runtime.Caller(1) - if ok { + if _, file, no, ok := runtime.Caller(1); ok { warningMsg = fmt.Sprintf("%s Called from %s:%d", warningMsg, file, no) } + fmt.Println(warningMsg) return inflect.Name(s) } diff --git a/middleware_test.go b/middleware_test.go index 487889eea..42553195e 100644 --- a/middleware_test.go +++ b/middleware_test.go @@ -148,13 +148,11 @@ func Test_Middleware_Skip_Resource(t *testing.T) { } a := New(Options{}) - var cr Resource - cr = &carsResource{&BaseResource{}} + var cr Resource = &carsResource{} g := a.Resource("/autos", cr) g.Use(mw1) - var ur Resource - ur = &carsResource{&BaseResource{}} + var ur Resource = &carsResource{} g = a.Resource("/cars", ur) g.Use(mw1) diff --git a/render/html.go b/render/html.go index 2c6374048..74b8f8fae 100644 --- a/render/html.go +++ b/render/html.go @@ -42,7 +42,7 @@ func (e *Engine) HTML(names ...string) Renderer { // MDTemplateEngine runs the input through github flavored markdown before sending it to the Plush engine. func MDTemplateEngine(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error) { if ct, ok := data["contentType"].(string); ok && ct == "text/plain" { - return plush.BuffaloRenderer(string(input), data, helpers) + return plush.BuffaloRenderer(input, data, helpers) } source := github_flavored_markdown.Markdown([]byte(input)) source = []byte(html.UnescapeString(string(source))) diff --git a/render/js_test.go b/render/js_test.go index b6743f315..1f6c7d84d 100644 --- a/render/js_test.go +++ b/render/js_test.go @@ -106,6 +106,7 @@ func Test_JavaScript_JS_Partial(t *testing.T) { tf, err := os.Create(filepath.Join(dir, "test.js")) r.NoError(err) _, err = tf.WriteString("let a = 1;\n<%= partial(\"part.js\") %>") + r.NoError(err) bb := &bytes.Buffer{} err = re.JavaScript("test.js").Render(bb, map[string]interface{}{}) @@ -137,6 +138,7 @@ func Test_JavaScript_HTML_Partial(t *testing.T) { tf, err := os.Create(filepath.Join(dir, "test.js")) r.NoError(err) _, err = tf.WriteString("let a = \"<%= partial(\"part.html\") %>\"") + r.NoError(err) bb := &bytes.Buffer{} err = re.JavaScript("test.js").Render(bb, map[string]interface{}{}) diff --git a/render/plain_test.go b/render/plain_test.go index 64db78c58..1838a797a 100644 --- a/render/plain_test.go +++ b/render/plain_test.go @@ -27,8 +27,6 @@ func Test_Plain(t *testing.T) { _, err = tmpFile.Write([]byte("<%= name %>")) r.NoError(err) - type ji func(...string) render.Renderer - j := render.New(render.Options{ TemplatesBox: packr.NewBox(tDir), }).Plain diff --git a/render/template_test.go b/render/template_test.go index 548be0223..66dc53fd3 100644 --- a/render/template_test.go +++ b/render/template_test.go @@ -64,8 +64,6 @@ func Test_Template_Partial(t *testing.T) { _, err = tmpFile.Write([]byte(`<%= partial("foo.html") %>`)) r.NoError(err) - type ji func(string, ...string) render.Renderer - j := render.New(render.Options{ TemplatesBox: packr.NewBox(tPath), }).Template @@ -97,8 +95,6 @@ func Test_Template_Partial_WithoutExtension(t *testing.T) { _, err = tmpFile.Write([]byte(`<%= partial("foo") %>`)) r.NoError(err) - type ji func(string, ...string) render.Renderer - j := render.New(render.Options{ TemplatesBox: packr.NewBox(tPath), }).HTML diff --git a/route.go b/route.go index 853bcb101..a438f1d93 100644 --- a/route.go +++ b/route.go @@ -114,10 +114,10 @@ func addExtraParamsTo(path string, opts map[string]interface{}) string { return path } - if strings.Contains(path, "?") == false { + if !strings.Contains(path, "?") { path = path + "?" } else { - if strings.HasSuffix(path, "?") == false { + if !strings.HasSuffix(path, "?") { path = path + "&" } } diff --git a/router_test.go b/router_test.go index 03908ea6c..0009648b8 100644 --- a/router_test.go +++ b/router_test.go @@ -349,11 +349,9 @@ func Test_App_NamedRoutes(t *testing.T) { r := require.New(t) a := New(Options{}) - var carsResource Resource - carsResource = CarsResource{&BaseResource{}} + var carsResource Resource = CarsResource{} - var resourcesResource Resource - resourcesResource = ResourcesResource{&BaseResource{}} + var resourcesResource Resource = ResourcesResource{} rr := render.New(render.Options{ HTMLLayout: "application.html",