Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Use goimports (#214)
Browse files Browse the repository at this point in the history
goimports fixes imports order and also formats like gofmt.
  • Loading branch information
VijayanB authored and yizheliu-amazon committed Aug 28, 2020
1 parent 670b0f0 commit 538f178
Show file tree
Hide file tree
Showing 25 changed files with 52 additions and 28 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/esad-cli-test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@ jobs:
- name: Check out AD CLI
uses: actions/checkout@v2

- name: gofmt
run: gofmt -s -w .
- name: Format
run: |
go get golang.org/x/tools/cmd/goimports
goimports -w .
- name: Check for modified files
id: git-check
run: |
echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Display unformated changes
if: steps.git-check.outputs.modified == 'true'
run: |
echo "Failed to format using go-fmt".
echo "Failed to format using goimports".
git diff
exit 1
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
Expand Down
1 change: 1 addition & 0 deletions cli/cmd/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
entity "esad/internal/entity/ad"
"esad/internal/handler/ad"
"fmt"

"github.com/spf13/cobra"
)

Expand Down
1 change: 1 addition & 0 deletions cli/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package cmd
import (
handler "esad/internal/handler/ad"
"fmt"

"github.com/spf13/cobra"
)

Expand Down
1 change: 1 addition & 0 deletions cli/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package cmd
import (
handler "esad/internal/handler/ad"
"fmt"

"github.com/spf13/cobra"
)

Expand Down
7 changes: 4 additions & 3 deletions cli/cmd/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import (
"esad/internal/client"
entity "esad/internal/entity/ad"
"fmt"
"os"
"strings"
"text/tabwriter"

"github.com/mitchellh/mapstructure"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/crypto/ssh/terminal"
"os"
"strings"
"text/tabwriter"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
handler "esad/internal/handler/ad"
"esad/pkg"
"fmt"
"os"
"path/filepath"

"github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
"path/filepath"
)

const (
Expand Down
1 change: 1 addition & 0 deletions cli/cmd/start_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"esad/internal/client"
"esad/internal/handler/ad"
"fmt"

"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ require (
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6 // indirect
golang.org/x/tools v0.0.0-20200820180210-c8f393745106 // indirect
gopkg.in/ini.v1 v1.57.0 // indirect
)
2 changes: 2 additions & 0 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6 h1:nULzSsKgihxFGLnQFv2T7lE5vIhOtg8ZPpJHapEt7o0=
golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200820180210-c8f393745106 h1:42Zs/g7pjhSIE/wiAuKcp8zp20zv7W2diNU6arpshOA=
golang.org/x/tools v0.0.0-20200820180210-c8f393745106/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/client/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ package client

import (
"crypto/tls"
"github.com/hashicorp/go-retryablehttp"
"net/http"

"github.com/hashicorp/go-retryablehttp"
)

//Client is an Abstraction for actual client
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/controller/ad/ad.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
cmapper "esad/internal/mapper"
mapper "esad/internal/mapper/ad"
"fmt"
"github.com/cheggaaa/pb/v3"
"io"
"os"
"strings"

"github.com/cheggaaa/pb/v3"
)

//go:generate mockgen -destination=mocks/mock_ad.go -package=mocks . Controller
Expand Down
5 changes: 3 additions & 2 deletions cli/internal/controller/ad/ad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
adgateway "esad/internal/gateway/ad/mocks"
mapper2 "esad/internal/mapper"
"fmt"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
)

const mockDetectorID = "m4ccEnIBTXsGi3mvMt9p"
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/controller/ad/mocks/mock_ad.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/internal/controller/es/es.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package es
import (
"context"
"encoding/json"
"esad/internal/entity/es"
elasticsearch "esad/internal/entity/es"
"esad/internal/gateway/es"
"fmt"
)
Expand Down
5 changes: 3 additions & 2 deletions cli/internal/controller/es/es_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import (
"context"
"errors"
gateway "esad/internal/gateway/es/mocks"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"io/ioutil"
"path/filepath"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
)

func helperLoadBytes(t *testing.T, name string) []byte {
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/controller/es/mocks/mock_es.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cli/internal/entity/ad/ad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ package ad
import (
"encoding/json"
"esad/internal/mapper"
"github.com/stretchr/testify/assert"
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func getRawFilter() []byte {
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/entity/es/es.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* permissions and limitations under the License.
*/

package elasticsearch
package es

//Terms contains fields
type Terms struct {
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/gateway/ad/ad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import (
"esad/internal/client"
"esad/internal/client/mocks"
"esad/internal/entity/ad"
"github.com/stretchr/testify/assert"
"io/ioutil"
"net/http"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
)

func helperLoadBytes(t *testing.T, name string) []byte {
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/gateway/ad/mocks/mock_ad.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cli/internal/gateway/es/es_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import (
"esad/internal/client"
"esad/internal/client/mocks"
elasticsearch "esad/internal/entity/es"
"github.com/stretchr/testify/assert"
"io/ioutil"
"net/http"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
)

func helperLoadBytes(t *testing.T, name string) []byte {
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/gateway/es/mocks/mock_es.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cli/internal/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
"encoding/json"
"esad/internal/client"
"fmt"
"github.com/hashicorp/go-retryablehttp"
"io/ioutil"
"net/url"

"github.com/hashicorp/go-retryablehttp"
)

//HTTPGateway type for gateway client
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/handler/ad/ad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
"esad/internal/controller/ad/mocks"
"esad/internal/entity/ad"
"esad/internal/mapper"
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"testing"
)

func getRawFilter() []byte {
Expand Down
3 changes: 2 additions & 1 deletion cli/internal/mapper/ad/ad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ package ad
import (
"esad/internal/entity/ad"
"esad/internal/mapper"
"github.com/stretchr/testify/assert"
"io/ioutil"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
)

func helperLoadBytes(t *testing.T, name string) []byte {
Expand Down

0 comments on commit 538f178

Please sign in to comment.