Skip to content

Commit

Permalink
chore: format codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
nodece committed Jun 22, 2023
1 parent 23e798c commit 5e59d59
Show file tree
Hide file tree
Showing 27 changed files with 72 additions and 40 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
GOFILES ?= $(shell find . -type f -name '*.go' | grep -v '.pb.go')

.PHONY: license-check
license-check:
find . -type f -name '*.go' | grep -v '.pb.go' | xargs go-license --config=.license.yml --verify
go-license --config=.license.yml --verify $(GOFILES)

.PHONY: license-format
license-format:
find . -type f -name '*.go' | grep -v '.pb.go' | xargs go-license --config=.license.yml
go-license --config=.license.yml $(GOFILES)

.PHONY: format
format: license-format
goimports -w $(GOFILES)
5 changes: 3 additions & 2 deletions client/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import (
"context"
"encoding/json"
"errors"
"log"
"time"

"github.com/casbin/casbin-mesh/proto/command"
"github.com/golang/protobuf/proto"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"google.golang.org/grpc"
"log"
"time"
)

type Client struct {
Expand Down
1 change: 1 addition & 0 deletions client/v2/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package client
import (
"context"
"encoding/base64"

"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)
Expand Down
15 changes: 8 additions & 7 deletions cmd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"github.com/casbin/casbin-mesh/pkg/auth"
"github.com/casbin/casbin-mesh/pkg/cluster"
"github.com/casbin/casbin-mesh/pkg/core"
"github.com/casbin/casbin-mesh/pkg/store"
"github.com/casbin/casbin-mesh/pkg/transport/tcp"
"github.com/rs/cors"
"github.com/soheilhy/cmux"
"io"
"io/ioutil"
"log"
Expand All @@ -38,6 +31,14 @@ import (
"runtime/pprof"
"strings"
"time"

"github.com/casbin/casbin-mesh/pkg/auth"
"github.com/casbin/casbin-mesh/pkg/cluster"
"github.com/casbin/casbin-mesh/pkg/core"
"github.com/casbin/casbin-mesh/pkg/store"
"github.com/casbin/casbin-mesh/pkg/transport/tcp"
"github.com/rs/cors"
"github.com/soheilhy/cmux"
)

func New(cfg *Config) (close func() error) {
Expand Down
9 changes: 5 additions & 4 deletions cmd/cli/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/c-bata/go-prompt"
"github.com/casbin/casbin-mesh/client/v2"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/tidwall/pretty"
"log"
"os"
"strconv"
"strings"
"time"

"github.com/c-bata/go-prompt"
"github.com/casbin/casbin-mesh/client/v2"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/tidwall/pretty"
)

type Context interface {
Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ package main

import (
"fmt"
"os"

"github.com/erikgeiser/promptkit/selection"
"github.com/erikgeiser/promptkit/textinput"
"os"
)

const customTemplate = `
Expand Down
1 change: 1 addition & 0 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"fmt"

"github.com/c-bata/go-prompt"
"github.com/casbin/casbin-mesh/client/v2"
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package main

import (
"github.com/jedib0t/go-pretty/v6/table"
"os"
"strings"

"github.com/jedib0t/go-pretty/v6/table"
)

// CasbinRule represents a Casbin rule line.
Expand Down
3 changes: 2 additions & 1 deletion pkg/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import (
"encoding/csv"
"encoding/json"
"errors"
"strings"

"github.com/casbin/casbin/v2/model"
"github.com/casbin/casbin/v2/persist"
"github.com/dgraph-io/badger/v3"
"strings"
)

// CasbinRule represents a Casbin rule line.
Expand Down
7 changes: 4 additions & 3 deletions pkg/adapter/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
package adapter

import (
"io/ioutil"
"os"
"testing"

"github.com/casbin/casbin/v2"
"github.com/casbin/casbin/v2/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"io/ioutil"
"os"
"testing"
)

const testDB = "test.db"
Expand Down
3 changes: 2 additions & 1 deletion pkg/adapter/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package adapter

import (
"github.com/dgraph-io/badger/v3"
"time"

"github.com/dgraph-io/badger/v3"

"io"
"log"
"sync"
Expand Down
5 changes: 3 additions & 2 deletions pkg/adapter/badger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ package adapter

import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"os"
"strconv"
"testing"

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

type BadgerTestSuite struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/auth/credential_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package auth
import (
"encoding/json"
"errors"
"golang.org/x/crypto/bcrypt"
"io"

"golang.org/x/crypto/bcrypt"
)

// BasicAuthProvider is the interface an object must support to return basic auth information.
Expand Down
3 changes: 2 additions & 1 deletion pkg/cluster/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/casbin/casbin-mesh/pkg/auth"
"io/ioutil"
"log"
"net"
Expand All @@ -29,6 +28,8 @@ import (
"strings"
"time"

"github.com/casbin/casbin-mesh/pkg/auth"

"github.com/casbin/casbin-mesh/pkg/utils"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/cluster/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ package cluster
import (
"encoding/json"
"fmt"
"github.com/casbin/casbin-mesh/pkg/auth"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"time"

"github.com/casbin/casbin-mesh/pkg/auth"
)

const numAttempts int = 3
Expand Down
5 changes: 3 additions & 2 deletions pkg/cluster/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package cluster

import (
"github.com/stretchr/testify/assert"
"golang.org/x/net/nettest"
"net"
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/net/nettest"
)

func TestListener(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package core

import (
"context"

"github.com/casbin/casbin-mesh/pkg/auth"
"github.com/casbin/casbin-mesh/pkg/store"
"github.com/casbin/casbin-mesh/proto/command"
Expand Down
1 change: 1 addition & 0 deletions pkg/core/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"encoding/json"
"errors"

"github.com/casbin/casbin-mesh/pkg/auth"
grpc2 "github.com/casbin/casbin-mesh/pkg/handler/grpc"
"github.com/casbin/casbin-mesh/proto/command"
Expand Down
7 changes: 4 additions & 3 deletions pkg/core/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
http2 "net/http"

"github.com/casbin/casbin-mesh/pkg/auth"
"github.com/casbin/casbin-mesh/pkg/handler/http"
"github.com/go-playground/validator"
"golang.org/x/net/context"
"io"
"io/ioutil"
http2 "net/http"
)

type httpService struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/handler/grpc/basic_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import (
"encoding/base64"
"errors"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"log"
"net/http"
"strings"

"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)

var ErrUnauthorized = errors.New("unauthorized")
Expand Down
1 change: 1 addition & 0 deletions pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package log

import (
"fmt"

raftbadgerdb "github.com/BBVA/raft-badger"
"github.com/hashicorp/raft"
)
Expand Down
1 change: 1 addition & 0 deletions pkg/store/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package store

import (
"context"

"github.com/casbin/casbin-mesh/pkg/adapter"
"github.com/casbin/casbin-mesh/proto/command"
"github.com/golang/protobuf/proto"
Expand Down
3 changes: 2 additions & 1 deletion pkg/store/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package store

import (
"github.com/casbin/casbin-mesh/pkg/auth"
"log"

"github.com/casbin/casbin-mesh/pkg/auth"
)

// StoreConfig represents the configuration of the underlying Store.
Expand Down
3 changes: 2 additions & 1 deletion pkg/store/enforcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ package store
import (
"context"
"encoding/json"
_const "github.com/casbin/casbin-mesh/pkg/const"
"time"

_const "github.com/casbin/casbin-mesh/pkg/const"

"github.com/casbin/casbin/v2"

"github.com/casbin/casbin-mesh/proto/command"
Expand Down
5 changes: 3 additions & 2 deletions pkg/store/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/casbin/casbin-mesh/pkg/adapter"
"github.com/casbin/casbin-mesh/pkg/auth"
"io"
"io/ioutil"
"log"
"sync"
"time"

"github.com/casbin/casbin-mesh/pkg/adapter"
"github.com/casbin/casbin-mesh/pkg/auth"

model2 "github.com/casbin/casbin/v2/model"

"github.com/casbin/casbin/v2"
Expand Down
1 change: 1 addition & 0 deletions pkg/store/manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package store

import (
"context"

"github.com/casbin/casbin-mesh/proto/command"
"github.com/golang/protobuf/proto"
"github.com/hashicorp/raft"
Expand Down
5 changes: 3 additions & 2 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"errors"
"expvar"
"fmt"
"github.com/casbin/casbin-mesh/pkg/adapter"
"github.com/casbin/casbin-mesh/pkg/auth"
"log"
"os"
"path/filepath"
Expand All @@ -28,6 +26,9 @@ import (
"sync"
"time"

"github.com/casbin/casbin-mesh/pkg/adapter"
"github.com/casbin/casbin-mesh/pkg/auth"

"github.com/golang/protobuf/proto"

"github.com/casbin/casbin-mesh/proto/command"
Expand Down

0 comments on commit 5e59d59

Please sign in to comment.