Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] module imports are not sorted #2888

Open
morya opened this issue Nov 25, 2024 · 4 comments
Open

[BUG] module imports are not sorted #2888

morya opened this issue Nov 25, 2024 · 4 comments
Labels
bug Categorizes issue or PR as related to a bug.

Comments

@morya
Copy link
Contributor

morya commented Nov 25, 2024

OpenIM Server Version

v3.8.1

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

I think it would help to understand code better, maintain easily, if imports are sorted in order like std, third packages, privated packages from current module,

could I send a PR to fulfill this request?

Screenshots Link

No response

@morya morya added the bug Categorizes issue or PR as related to a bug. label Nov 25, 2024
@OpenIM-Robot
Copy link

Hello! Thank you for filing an issue.

If this is a bug report, please include relevant logs to help us debug the problem.

Join slack 🤖 to connect and communicate with our developers.

@skiffer-git
Copy link
Member

Thank you for contributing code to OpenIM.

@skiffer-git
Copy link
Member

Yes, feel free to submit a PR to address this request.

@morya
Copy link
Contributor Author

morya commented Nov 30, 2024

I think it could more organized, readable, and maitianable, if code imports were sorted like these:

import(

"standard" ...

"third-party"

"copany-libs"

"current-module"
)

for example, content from repo file ./internal/api/router.go

https://github.com/openimsdk/open-im-server/blob/83ac4e83b98824f620c06b11a46bbdadee908e71/internal/api/router.go#L3:L28

could be formatted with gci tool, with command like this:

files=`find internal -type f -name "*.go"`
for f in $files; do
    gci write \
    -s standard \
    -s default \
    -s 'prefix(github.com/openimsdk)' \
    -s localmodule $filename
done

which will turn out be :

package api

import (
	"fmt"
	"net/http"
	"strings"

	"github.com/gin-contrib/gzip"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
	"github.com/go-playground/validator/v10"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"

	"github.com/openimsdk/protocol/constant"
	"github.com/openimsdk/tools/apiresp"
	"github.com/openimsdk/tools/discovery"
	"github.com/openimsdk/tools/log"
	"github.com/openimsdk/tools/mw"

	"github.com/openimsdk/open-im-server/v3/internal/api/jssdk"
	"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
	"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
	"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants