You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/05/13 14:59:41 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5844: Circumvent copylocks `go vet` check using unsafe Go

ocket8888 commented on a change in pull request #5844:
URL: https://github.com/apache/trafficcontrol/pull/5844#discussion_r631876688



##########
File path: grove/remap/remap.go
##########
@@ -497,7 +498,11 @@ func makeTo(tosJSON []RemapRuleToJSON, rule remapdata.RemapRule, baseTransport *
 				return nil, fmt.Errorf("error parsing to %v proxy_url: %v", to.URL, toJSON.ProxyURL)
 			}
 			to.ProxyURL = proxyURL
-			newTransport := *baseTransport
+			newTransport := http.Transport{}
+			const transportSize = unsafe.Sizeof(*baseTransport)
+			// Copy baseTransport to newTransport without failing the copylocks `go vet` check. See
+			// b7953cc239 for the reasoning behind copying the Transport.
+			copy((*[transportSize]byte)(unsafe.Pointer(&newTransport))[:], (*[transportSize]byte)(unsafe.Pointer(baseTransport))[:])

Review comment:
       I, too, was hoping there was a way to do this without `unsafe`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org