mirror of
				https://github.com/mgechev/revive.git
				synced 2025-10-30 23:37:49 +02:00 
			
		
		
		
	This commit is contained in:
		| @@ -60,9 +60,9 @@ func (l *lintTimeEqual) Visit(node ast.Node) ast.Visitor { | ||||
| 	var failure string | ||||
| 	switch expr.Op { | ||||
| 	case token.EQL: | ||||
| 		failure = fmt.Sprintf("use %s.Equal(%s) instead of %q operator", expr.X, expr.Y, expr.Op) | ||||
| 		failure = fmt.Sprintf("use %s.Equal(%s) instead of %q operator", gofmt(expr.X), gofmt(expr.Y), expr.Op) | ||||
| 	case token.NEQ: | ||||
| 		failure = fmt.Sprintf("use !%s.Equal(%s) instead of %q operator", expr.X, expr.Y, expr.Op) | ||||
| 		failure = fmt.Sprintf("use !%s.Equal(%s) instead of %q operator", gofmt(expr.X), gofmt(expr.Y), expr.Op) | ||||
| 	} | ||||
|  | ||||
| 	l.onFailure(lint.Failure{ | ||||
|   | ||||
							
								
								
									
										4
									
								
								testdata/time-equal.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								testdata/time-equal.go
									
									
									
									
										vendored
									
									
								
							| @@ -12,3 +12,7 @@ func t() bool { | ||||
|  | ||||
| 	return t != u // MATCH /use !t.Equal(u) instead of "!=" operator/ | ||||
| } | ||||
|  | ||||
| // issue #846 | ||||
| func isNow(t time.Time) bool    { return t == time.Now() } // MATCH /use t.Equal(time.Now()) instead of "==" operator/ | ||||
| func isNotNow(t time.Time) bool { return time.Now() != t } // MATCH /use !time.Now().Equal(t) instead of "!=" operator/ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user