Skip to content

Modernize codebase using go fix #2391

Description

@kznLeaf

Thank you for maintaining the bleve project. I would like to propose a code optimization suggestion.

The idea came up while I was using bleve API and noticed that interface{} types haven't been replaced with any yet. Considering that the Go team enhanced the go fix command a few months ago (See: https://go.dev/blog/gofix ), I tried running:

go fix ./...

in the root directory. This made 410 changes. I roughly reviewed the changes which mainly include:

  1. Replacing interface{} with any, which accounts for the majority of the changes.
  2. Replacing certain logic with more idiomatic Go implementations, such as using strings.Builder for more efficient string concatenation and preferring range loops where appropriate:
Image Image
  1. Leveraging newer built-in functions to reduce redundancy, such as replacing manual max/min calculations with built-in max and min. For example:
Image

Therefore my suggestion is that you can use go fix to modernize and standardize the codebase, and I believe this would be meaningful for maintaining overall code quality.

(English is not my native language, so I used machine translation to help write this text. Please excuse any awkward phrasing :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions