Skip to content

Commit

Permalink
save comments on parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
incu6us committed Apr 9, 2020
1 parent f7a91b8 commit 08058a5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/incu6us/goimport-reviser
module github.com/incu6us/goimports-reviser

go 1.13

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"strings"

"github.com/incu6us/goimport-reviser/reviser"
"github.com/incu6us/goimports-reviser/reviser"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions reviser/reviser.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (

"github.com/pkg/errors"

"github.com/incu6us/goimport-reviser/helper"
"github.com/incu6us/goimports-reviser/helper"
)

func Execute(projectName, filePath string) ([]byte, error) {
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, filePath, nil, 0)

f, err := parser.ParseFile(fset, filePath, nil, parser.ParseComments)
if err != nil {
log.Println(err)
return nil, errors.WithStack(err)
Expand Down
6 changes: 5 additions & 1 deletion reviser/reviser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestExecute(t *testing.T) {
wantErr bool
}{
{
name: "success",
name: "success with comments",
args: args{
projectName: "github.com/incu6us/goimport-reviser",
filePath: "./testdata/example.go",
Expand All @@ -35,6 +35,8 @@ import (
"github.com/pkg/errors"
)
// nolint:gomnd
`,
},
want: `package testdata
Expand All @@ -47,6 +49,8 @@ import (
"github.com/incu6us/goimport-reviser/testdata/innderpkg"
)
// nolint:gomnd
`,
wantErr: false,
},
Expand Down

0 comments on commit 08058a5

Please sign in to comment.