Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb7f62b

Browse files
authored
fix: formats consistently the code with gci (#5893)
1 parent223ff51 commitdb7f62b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎pkg/goformatters/gci/gci.go‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gci
22

33
import (
44
"context"
5+
"go/format"
56

67
gcicfg"github.com/daixiang0/gci/pkg/config"
78
"github.com/daixiang0/gci/pkg/gci"
@@ -60,5 +61,14 @@ func (*Formatter) Name() string {
6061

6162
func (f*Formatter)Format(filenamestring,src []byte) ([]byte,error) {
6263
_,formatted,err:=gci.LoadFormat(src,filename,*f.config)
63-
returnformatted,err
64+
iferr!=nil {
65+
returnnil,err
66+
}
67+
68+
// gci format the code only when the imports are modified,
69+
// this produced inconsistencies.
70+
// To be always consistent, the code should always be formatted.
71+
// https://github.com/daixiang0/gci/blob/c4f689991095c0e54843dca76fb9c3bad58ec5c7/pkg/gci/gci.go#L148-L151
72+
// https://github.com/daixiang0/gci/blob/c4f689991095c0e54843dca76fb9c3bad58ec5c7/pkg/gci/gci.go#L215
73+
returnformat.Source(formatted)
6474
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp