Use Cleanup to remove old entries in ts map
This commit is contained in:
		
							parent
							
								
									fe8a28286e
								
							
						
					
					
						commit
						d20ac9444a
					
				
					 2 changed files with 5 additions and 0 deletions
				
			
		|  | @ -24,6 +24,10 @@ func New(t T) Assert { | ||||||
| 	f := runtime.FuncForPC(reflect.ValueOf(a).Pointer()) | 	f := runtime.FuncForPC(reflect.ValueOf(a).Pointer()) | ||||||
| 	ts[f] = t | 	ts[f] = t | ||||||
| 
 | 
 | ||||||
|  | 	t.Cleanup(func() { | ||||||
|  | 		delete(ts, f) | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
| 	return a | 	return a | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								type.go
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								type.go
									
										
									
									
									
								
							|  | @ -4,4 +4,5 @@ package assert | ||||||
| type T interface { | type T interface { | ||||||
| 	Error(...interface{}) | 	Error(...interface{}) | ||||||
| 	Helper() | 	Helper() | ||||||
|  | 	Cleanup(func()) | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue