mirror of
				https://github.com/mgechev/revive.git
				synced 2025-10-30 23:37:49 +02:00 
			
		
		
		
	fix: panic with getFieldTypeName (#1229)
* fix: panic with interface type and array * replaces panic with a return of a default string * review --------- Co-authored-by: chavacava <salvadorcavadini+github@gmail.com>
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							3e3e9825db
						
					
				
				
					commit
					9a54195228
				
			| @@ -2,7 +2,6 @@ | ||||
| package astutils | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"go/ast" | ||||
| ) | ||||
|  | ||||
| @@ -73,7 +72,11 @@ func getFieldTypeName(typ ast.Expr) string { | ||||
| 		return "*" + getFieldTypeName(f.X) | ||||
| 	case *ast.IndexExpr: | ||||
| 		return getFieldTypeName(f.X) + "[" + getFieldTypeName(f.Index) + "]" | ||||
| 	case *ast.ArrayType: | ||||
| 		return "[]" + getFieldTypeName(f.Elt) | ||||
| 	case *ast.InterfaceType: | ||||
| 		return "interface{}" | ||||
| 	default: | ||||
| 		panic(fmt.Sprintf("not supported type %T", typ)) | ||||
| 		return "UNHANDLED_TYPE" | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										9
									
								
								testdata/golint/sort.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								testdata/golint/sort.go
									
									
									
									
										vendored
									
									
								
							| @@ -44,3 +44,12 @@ func (x X) Less(i *pkg.tip) (result bool) { return len(x) } // MATCH /exported m | ||||
|  | ||||
| // Test for issue #1217 | ||||
| func (s *synchronized[T]) Swap(other Synchronized[T]) {} | ||||
|  | ||||
| // Swap for issue #1228 | ||||
| func (s *synchronized[T]) Swap(other interface{}) {} | ||||
|  | ||||
| // Swap for issue #1228 | ||||
| func (s *synchronized[T]) Swap(other []int) {} | ||||
|  | ||||
| // Swap for issue #1228 | ||||
| func (s *synchronized[T]) Swap(other []interface{}) {} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user