Repository: mgechev/revive (go)

Issue:
import-shadowing shouldn't check current package name
**Describe the bug**
```go
// File: github.com/powerman/go-monolith-example/ms/auth/internal/config/config.go
package config
import "github.com/powerman/go-monolith-example/internal/config"
```
```
ms/auth/internal/config/config.go:11:9: import-shadowing: The name 'config' shadows an import name (revive)
package config
        ^
```

**To Reproduce**
I use revive bundled with golangci-lint 1.41.1.

**Expected behavior**
Within package named "x" we should be able to import/create identifiers with same name "x" - there is no shadowing in this case.

**Desktop (please complete the following information):**
 - OS: Gentoo Linux
 - go version go1.16.5 linux/amd64

Pull request:
fix 534
Closes #534 


Patch:
diff --git a/rule/import-shadowing.go b/rule/import-shadowing.go
index b78234c..7b34c90 100644
--- a/rule/import-shadowing.go
+++ b/rule/import-shadowing.go
@@ -23,7 +23,8 @@ func (r *ImportShadowingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Fa
 
 	fileAst := file.AST
 	walker := importShadowing{
-		importNames: importNames,
+		packageNameIdent: fileAst.Name,
+		importNames:      importNames,
 		onFailure: func(failure lint.Failure) {
 			failures = append(failures, failure)
 		},
@@ -57,9 +58,10 @@ func getName(imp *ast.ImportSpec) string {
 }
 
 type importShadowing struct {
-	importNames map[string]struct{}
-	onFailure   func(lint.Failure)
-	alreadySeen map[*ast.Object]struct{}
+	packageNameIdent *ast.Ident
+	importNames      map[string]struct{}
+	onFailure        func(lint.Failure)
+	alreadySeen      map[*ast.Object]struct{}
 }
 
 // Visit visits AST nodes and checks if id nodes (ast.Ident) shadow an import name
@@ -79,6 +81,10 @@ func (w importShadowing) Visit(n ast.Node) ast.Visitor {
 		*ast.StructType:   // skip analysis of struct type because struct fields can not shadow an import name
 		return nil
 	case *ast.Ident:
+		if n == w.packageNameIdent {
+			return nil // skip the ident corresponding to the package name of this file
+		}
+
 		id := n.Name
 		if id == "_" {
 			return w // skip _ id


Test patch:
diff --git a/testdata/import-shadowing.go b/testdata/import-shadowing.go
index 06f91f6..124f108 100644
--- a/testdata/import-shadowing.go
+++ b/testdata/import-shadowing.go
@@ -8,6 +8,7 @@ import (
 	_ "net/http"
 	"strings"
 	str "strings"
+	"fixtures" // Test case for issue #534
 )
 
 const str = "" // MATCH /The name 'str' shadows an import name/