Skip to content

Commit

Permalink
fix linebreak issue (#75)
Browse files Browse the repository at this point in the history
Signed-off-by: Loong Dai <loong.dai@intel.com>
  • Loading branch information
daixiang0 authored Jul 13, 2022
1 parent 03acdea commit c0bd0a2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/gci/gci.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ func LoadFormatGoFile(file io.FileObj, cfg config.Config) (src, dist []byte, err
body = append(body, utils.Linebreak)
}
}
}

// remove breakline in the end
// remove breakline in the end
if body[len(body)-1] == utils.Linebreak && tail[0] == utils.Linebreak {
body = body[:len(body)-1]
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/gci/internal/testdata/linebreak-no-custom.cfg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sections:
- Standard
- Default
- Prefix(github.com/daixiang0)
7 changes: 7 additions & 0 deletions pkg/gci/internal/testdata/linebreak-no-custom.in.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main
import (
g "github.com/golang"

"fmt"

)
6 changes: 6 additions & 0 deletions pkg/gci/internal/testdata/linebreak-no-custom.out.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main
import (
"fmt"

g "github.com/golang"
)
4 changes: 4 additions & 0 deletions pkg/gci/internal/testdata/linebreak.cfg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sections:
- Standard
- Default
- Prefix(github.com/daixiang0)
9 changes: 9 additions & 0 deletions pkg/gci/internal/testdata/linebreak.in.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main
import (
g "github.com/golang"

"fmt"

"github.com/daixiang0/gci"

)
8 changes: 8 additions & 0 deletions pkg/gci/internal/testdata/linebreak.out.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main
import (
"fmt"

g "github.com/golang"

"github.com/daixiang0/gci"
)

0 comments on commit c0bd0a2

Please sign in to comment.