Repository: casbin/casbin
Pull request #525 (2020-07-15 07:50:15)

fix: update module to v3
Signed-off-by: Zixuan Liu <nodeces@gmail.com>

coveralls: 
[![Coverage Status](https://coveralls.io/builds/32077943/badge)](https://coveralls.io/builds/32077943)

Coverage remained the same at 74.552% when pulling **4bdd934c64fded18bda348ccfe3ddafef3c01179 on nodece:master** into **bcf37dacf1c584d068ffe66d8e659525e9288f40 on casbin:release-3.0.0**.

hsluoyz: Is it right to label this PR as "fix"? I originally thought this PR will be breaking change to update version from v2 to v3?
nodece: I should add breaking change to commit history.  currently,  the branch is disable semantic-release.

Patch:
diff --git a/README.md b/README.md
index 6f4e6ba..073ef51 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Casbin
 [![Go Report Card](https://goreportcard.com/badge/github.com/casbin/casbin)](https://goreportcard.com/report/github.com/casbin/casbin)
 [![Build Status](https://travis-ci.org/casbin/casbin.svg?branch=master)](https://travis-ci.org/casbin/casbin)
 [![Coverage Status](https://coveralls.io/repos/github/casbin/casbin/badge.svg?branch=master)](https://coveralls.io/github/casbin/casbin?branch=master)
-[![Godoc](https://godoc.org/github.com/casbin/casbin?status.svg)](https://pkg.go.dev/github.com/casbin/casbin/v2)
+[![Godoc](https://godoc.org/github.com/casbin/casbin?status.svg)](https://pkg.go.dev/github.com/casbin/casbin/v3)
 [![Release](https://img.shields.io/github/release/casbin/casbin.svg)](https://github.com/casbin/casbin/releases/latest)
 [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/casbin/lobby)
 [![Sourcegraph](https://sourcegraph.com/github.com/casbin/casbin/-/badge.svg)](https://sourcegraph.com/github.com/casbin/casbin?badge)
diff --git a/enforcer.go b/enforcer.go
index 706c556..7379d89 100644
--- a/enforcer.go
+++ b/enforcer.go
@@ -20,14 +20,14 @@ import (
 	"strings"
 
 	"github.com/Knetic/govaluate"
-	"github.com/casbin/casbin/v2/effect"
-	"github.com/casbin/casbin/v2/log"
-	"github.com/casbin/casbin/v2/model"
-	"github.com/casbin/casbin/v2/persist"
-	fileadapter "github.com/casbin/casbin/v2/persist/file-adapter"
-	"github.com/casbin/casbin/v2/rbac"
-	defaultrolemanager "github.com/casbin/casbin/v2/rbac/default-role-manager"
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/effect"
+	"github.com/casbin/casbin/v3/log"
+	"github.com/casbin/casbin/v3/model"
+	"github.com/casbin/casbin/v3/persist"
+	fileadapter "github.com/casbin/casbin/v3/persist/file-adapter"
+	"github.com/casbin/casbin/v3/rbac"
+	defaultrolemanager "github.com/casbin/casbin/v3/rbac/default-role-manager"
+	"github.com/casbin/casbin/v3/util"
 )
 
 // Enforcer is the main interface for authorization enforcement and policy management.
diff --git a/enforcer_interface.go b/enforcer_interface.go
index f414c1d..f0ebbcf 100644
--- a/enforcer_interface.go
+++ b/enforcer_interface.go
@@ -16,10 +16,10 @@ package casbin
 
 import (
 	"github.com/Knetic/govaluate"
-	"github.com/casbin/casbin/v2/effect"
-	"github.com/casbin/casbin/v2/model"
-	"github.com/casbin/casbin/v2/persist"
-	"github.com/casbin/casbin/v2/rbac"
+	"github.com/casbin/casbin/v3/effect"
+	"github.com/casbin/casbin/v3/model"
+	"github.com/casbin/casbin/v3/persist"
+	"github.com/casbin/casbin/v3/rbac"
 )
 
 var _ IEnforcer = &Enforcer{}
diff --git a/enforcer_synced.go b/enforcer_synced.go
index 6943447..7644403 100644
--- a/enforcer_synced.go
+++ b/enforcer_synced.go
@@ -20,8 +20,8 @@ import (
 	"time"
 
 	"github.com/Knetic/govaluate"
-	"github.com/casbin/casbin/v2/log"
-	"github.com/casbin/casbin/v2/persist"
+	"github.com/casbin/casbin/v3/log"
+	"github.com/casbin/casbin/v3/persist"
 )
 
 // SyncedEnforcer wraps Enforcer and provides synchronized access
diff --git a/go.mod b/go.mod
index c6c765a..114ef5f 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module github.com/casbin/casbin/v2
+module github.com/casbin/casbin/v3
 
 require github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible
 
diff --git a/internal_api.go b/internal_api.go
index 2ae9039..ce20b9f 100644
--- a/internal_api.go
+++ b/internal_api.go
@@ -15,8 +15,8 @@
 package casbin
 
 import (
-	"github.com/casbin/casbin/v2/model"
-	"github.com/casbin/casbin/v2/persist"
+	"github.com/casbin/casbin/v3/model"
+	"github.com/casbin/casbin/v3/persist"
 )
 
 const (
diff --git a/model/assertion.go b/model/assertion.go
index 2917318..65de9b1 100644
--- a/model/assertion.go
+++ b/model/assertion.go
@@ -18,8 +18,8 @@ import (
 	"errors"
 	"strings"
 
-	"github.com/casbin/casbin/v2/log"
-	"github.com/casbin/casbin/v2/rbac"
+	"github.com/casbin/casbin/v3/log"
+	"github.com/casbin/casbin/v3/rbac"
 )
 
 // Assertion represents an expression in a section of the model.
diff --git a/model/function.go b/model/function.go
index 1f7ddd9..8683f1f 100644
--- a/model/function.go
+++ b/model/function.go
@@ -18,7 +18,7 @@ import (
 	"sync"
 
 	"github.com/Knetic/govaluate"
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/util"
 )
 
 // FunctionMap represents the collection of Function.
diff --git a/model/model.go b/model/model.go
index 99b0758..ae1cdfa 100644
--- a/model/model.go
+++ b/model/model.go
@@ -19,9 +19,9 @@ import (
 	"strconv"
 	"strings"
 
-	"github.com/casbin/casbin/v2/config"
-	"github.com/casbin/casbin/v2/log"
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/config"
+	"github.com/casbin/casbin/v3/log"
+	"github.com/casbin/casbin/v3/util"
 )
 
 // Model represents the whole access control model.
diff --git a/model/policy.go b/model/policy.go
index fe5c10a..e7b8790 100644
--- a/model/policy.go
+++ b/model/policy.go
@@ -17,9 +17,9 @@ package model
 import (
 	"strings"
 
-	"github.com/casbin/casbin/v2/log"
-	"github.com/casbin/casbin/v2/rbac"
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/log"
+	"github.com/casbin/casbin/v3/rbac"
+	"github.com/casbin/casbin/v3/util"
 )
 
 type (
diff --git a/persist/adapter.go b/persist/adapter.go
index 5e1ec1e..c142820 100644
--- a/persist/adapter.go
+++ b/persist/adapter.go
@@ -18,7 +18,7 @@ import (
 	"encoding/csv"
 	"strings"
 
-	"github.com/casbin/casbin/v2/model"
+	"github.com/casbin/casbin/v3/model"
 )
 
 // LoadPolicyLine loads a text line as a policy rule to model.
diff --git a/persist/adapter_filtered.go b/persist/adapter_filtered.go
index 82c9a0e..f4be4a6 100644
--- a/persist/adapter_filtered.go
+++ b/persist/adapter_filtered.go
@@ -15,7 +15,7 @@
 package persist
 
 import (
-	"github.com/casbin/casbin/v2/model"
+	"github.com/casbin/casbin/v3/model"
 )
 
 // FilteredAdapter is the interface for Casbin adapters supporting filtered policies.
diff --git a/persist/file-adapter/adapter.go b/persist/file-adapter/adapter.go
index 5b08d7a..7229d98 100644
--- a/persist/file-adapter/adapter.go
+++ b/persist/file-adapter/adapter.go
@@ -21,9 +21,9 @@ import (
 	"os"
 	"strings"
 
-	"github.com/casbin/casbin/v2/model"
-	"github.com/casbin/casbin/v2/persist"
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/model"
+	"github.com/casbin/casbin/v3/persist"
+	"github.com/casbin/casbin/v3/util"
 )
 
 // Adapter is the file adapter for Casbin.
diff --git a/persist/file-adapter/adapter_filtered.go b/persist/file-adapter/adapter_filtered.go
index 924ef2d..8d55e30 100644
--- a/persist/file-adapter/adapter_filtered.go
+++ b/persist/file-adapter/adapter_filtered.go
@@ -20,8 +20,8 @@ import (
 	"os"
 	"strings"
 
-	"github.com/casbin/casbin/v2/model"
-	"github.com/casbin/casbin/v2/persist"
+	"github.com/casbin/casbin/v3/model"
+	"github.com/casbin/casbin/v3/persist"
 )
 
 // FilteredAdapter is the filtered file adapter for Casbin. It can load policy
diff --git a/persist/file-adapter/adapter_mock.go b/persist/file-adapter/adapter_mock.go
index b9c71d8..e16742d 100644
--- a/persist/file-adapter/adapter_mock.go
+++ b/persist/file-adapter/adapter_mock.go
@@ -21,8 +21,8 @@ import (
 	"os"
 	"strings"
 
-	"github.com/casbin/casbin/v2/model"
-	"github.com/casbin/casbin/v2/persist"
+	"github.com/casbin/casbin/v3/model"
+	"github.com/casbin/casbin/v3/persist"
 )
 
 // AdapterMock is the file adapter for Casbin.
diff --git a/persist/watcher_ex.go b/persist/watcher_ex.go
index 24ce953..cebaa85 100644
--- a/persist/watcher_ex.go
+++ b/persist/watcher_ex.go
@@ -14,7 +14,7 @@
 
 package persist
 
-import "github.com/casbin/casbin/v2/model"
+import "github.com/casbin/casbin/v3/model"
 
 // WatcherEx is the strengthen for Casbin watchers.
 type WatcherEx interface {
diff --git a/rbac/default-role-manager/role_manager.go b/rbac/default-role-manager/role_manager.go
index 98d4c23..f81b21a 100644
--- a/rbac/default-role-manager/role_manager.go
+++ b/rbac/default-role-manager/role_manager.go
@@ -18,9 +18,9 @@ import (
 	"strings"
 	"sync"
 
-	"github.com/casbin/casbin/v2/errors"
-	"github.com/casbin/casbin/v2/log"
-	"github.com/casbin/casbin/v2/rbac"
+	"github.com/casbin/casbin/v3/errors"
+	"github.com/casbin/casbin/v3/log"
+	"github.com/casbin/casbin/v3/rbac"
 )
 
 const defaultDomain string = "casbin::default"
diff --git a/rbac_api.go b/rbac_api.go
index c222dd2..1fff9f4 100644
--- a/rbac_api.go
+++ b/rbac_api.go
@@ -17,7 +17,7 @@ package casbin
 import (
 	"errors"
 
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/util"
 )
 
 // GetRolesForUser gets the roles that a user has.
diff --git a/util/builtin_operators.go b/util/builtin_operators.go
index 717c7e9..89ed327 100755
--- a/util/builtin_operators.go
+++ b/util/builtin_operators.go
@@ -23,7 +23,7 @@ import (
 	"strings"
 
 	"github.com/Knetic/govaluate"
-	"github.com/casbin/casbin/v2/rbac"
+	"github.com/casbin/casbin/v3/rbac"
 )
 
 // validate the variadic parameter size and type as string


Test patch:
diff --git a/enforcer_test.go b/enforcer_test.go
index 726a04f..5dde46d 100644
--- a/enforcer_test.go
+++ b/enforcer_test.go
@@ -18,9 +18,9 @@ import (
 	"sync"
 	"testing"
 
-	"github.com/casbin/casbin/v2/model"
-	fileadapter "github.com/casbin/casbin/v2/persist/file-adapter"
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/model"
+	fileadapter "github.com/casbin/casbin/v3/persist/file-adapter"
+	"github.com/casbin/casbin/v3/util"
 )
 
 func TestKeyMatchModelInMemory(t *testing.T) {
diff --git a/error_test.go b/error_test.go
index 1e950d4..b44529d 100644
--- a/error_test.go
+++ b/error_test.go
@@ -17,7 +17,7 @@ package casbin
 import (
 	"testing"
 
-	"github.com/casbin/casbin/v2/persist/file-adapter"
+	"github.com/casbin/casbin/v3/persist/file-adapter"
 )
 
 func TestPathError(t *testing.T) {
diff --git a/filter_test.go b/filter_test.go
index 3a3c5f6..96e108c 100644
--- a/filter_test.go
+++ b/filter_test.go
@@ -17,7 +17,7 @@ package casbin
 import (
 	"testing"
 
-	"github.com/casbin/casbin/v2/persist/file-adapter"
+	"github.com/casbin/casbin/v3/persist/file-adapter"
 )
 
 func TestInitFilteredAdapter(t *testing.T) {
diff --git a/management_api_test.go b/management_api_test.go
index db945aa..a278717 100644
--- a/management_api_test.go
+++ b/management_api_test.go
@@ -17,7 +17,7 @@ package casbin
 import (
 	"testing"
 
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/util"
 )
 
 func testStringList(t *testing.T, title string, f func() []string, res []string) {
diff --git a/model/model_test.go b/model/model_test.go
index bfce615..9a320f9 100644
--- a/model/model_test.go
+++ b/model/model_test.go
@@ -15,7 +15,7 @@
 package model
 
 import (
-	"github.com/casbin/casbin/v2/config"
+	"github.com/casbin/casbin/v3/config"
 	"io/ioutil"
 	"path/filepath"
 	"strings"
diff --git a/model_test.go b/model_test.go
index 00efd9b..5ee316e 100644
--- a/model_test.go
+++ b/model_test.go
@@ -17,10 +17,10 @@ package casbin
 import (
 	"testing"
 
-	fileadapter "github.com/casbin/casbin/v2/persist/file-adapter"
-	"github.com/casbin/casbin/v2/rbac"
-	defaultrolemanager "github.com/casbin/casbin/v2/rbac/default-role-manager"
-	"github.com/casbin/casbin/v2/util"
+	fileadapter "github.com/casbin/casbin/v3/persist/file-adapter"
+	"github.com/casbin/casbin/v3/rbac"
+	defaultrolemanager "github.com/casbin/casbin/v3/rbac/default-role-manager"
+	"github.com/casbin/casbin/v3/util"
 )
 
 func testEnforce(t *testing.T, e *Enforcer, sub interface{}, obj interface{}, act string, res bool) {
diff --git a/rbac/default-role-manager/role_manager_test.go b/rbac/default-role-manager/role_manager_test.go
index b8c1756..5a1020d 100644
--- a/rbac/default-role-manager/role_manager_test.go
+++ b/rbac/default-role-manager/role_manager_test.go
@@ -17,8 +17,8 @@ package defaultrolemanager
 import (
 	"testing"
 
-	"github.com/casbin/casbin/v2/rbac"
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/rbac"
+	"github.com/casbin/casbin/v3/util"
 )
 
 func testRole(t *testing.T, rm rbac.RoleManager, name1 string, name2 string, res bool) {
diff --git a/rbac_api_test.go b/rbac_api_test.go
index b41cb11..886babb 100644
--- a/rbac_api_test.go
+++ b/rbac_api_test.go
@@ -18,10 +18,10 @@ import (
 	"sort"
 	"testing"
 
-	defaultrolemanager "github.com/casbin/casbin/v2/rbac/default-role-manager"
+	defaultrolemanager "github.com/casbin/casbin/v3/rbac/default-role-manager"
 
-	"github.com/casbin/casbin/v2/errors"
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/errors"
+	"github.com/casbin/casbin/v3/util"
 )
 
 func testGetRoles(t *testing.T, e *Enforcer, res []string, name string, domain ...string) {
diff --git a/rbac_api_with_domains_test.go b/rbac_api_with_domains_test.go
index e4c10a1..542a40c 100644
--- a/rbac_api_with_domains_test.go
+++ b/rbac_api_with_domains_test.go
@@ -17,7 +17,7 @@ package casbin
 import (
 	"testing"
 
-	"github.com/casbin/casbin/v2/util"
+	"github.com/casbin/casbin/v3/util"
 )
 
 // testGetUsersInDomain: Add by Gordon
diff --git a/watcher_ex_test.go b/watcher_ex_test.go
index 12c0f5d..ab13f44 100644
--- a/watcher_ex_test.go
+++ b/watcher_ex_test.go
@@ -17,7 +17,7 @@ package casbin
 import (
 	"testing"
 
-	"github.com/casbin/casbin/v2/model"
+	"github.com/casbin/casbin/v3/model"
 )
 
 type SampleWatcherEx struct {