Capturing Go Traffic
Fiddler captures different traffic but I cannot capture localhost HTTP traffic generated from a Go application.
Solution
Fiddler Everywhere respects global variables like HTTP_PROXY which are also used by the HttpProxy and useProxy in the Go language.
However, a known limitation is that the above Go methods won't respect the proxy variables for traffic going through localhost or 127.0.0.1 because if req.URL.Host is localhost or a loopback address (with or without a port number), then a nil URL and nil error will be returned.
To overcome the above limitation, you can explicitly overwrite the hosts file in your operating system and provide a custom alias for the localhost traffic.
For example:
Open the hosts file on macOS
open ~/etc/hosts
or open the hosts file on Windows
start c:/Windows/System32/Drivers/etc/hosts
Then add an alias like local for the localhost address 127.0.0.1
127.0.0.1 local
Finally, open your Go application and substitute any mentions of localhost or 127.0.0.1 with the new alias local.