The go get command itself does not have a built-in flag to directly show detailed network traffic or redirections. However, you can use a combination of tools and techniques to inspect what is happening under the hood when you run go get. Here are a few methods to achieve this:
1. Use GOPROXY Environment Variable
You can set the GOPROXY environment variable to use a proxy that logs requests. This can help you see the actual URLs being accessed.
export GOPROXY=https://proxy.golang.org
go get appliedgo.net/proverbs
While this won't show redirections directly, it will show you the URLs being accessed by the Go toolchain.
2. Use curl or wget to Inspect URLs
You can manually inspect the URLs using curl or wget to see if there are any redirections.
curl -I https://proxy.golang.org/appliedgo.net/proverbs/@v/v0.0.0-20230101000000-abcdef123456.zip
This command will show you the HTTP headers, including any redirections.
3. Use go env to Check Proxy Settings
You can check the current proxy settings using the go env command.
go env GOPROXY
This will show you the current proxy settings, which can give you an idea of where the requests are being sent.
4. Use Network Monitoring Tools
You can use network monitoring tools like tcpdump, Wireshark, or browser developer tools to inspect the network traffic generated by go get.
Example with tcpdump:
sudo tcpdump -i any port 443
This command will capture all HTTPS traffic on your machine. You can then analyze the captured packets to see the actual URLs being accessed and any redirections.
5. Use go mod download
The go mod download command can be used to download the modules specified in the go.mod file. You can combine this with network monitoring tools to inspect the traffic.
go mod download
6. Use go mod verify
The go mod verify command can be used to verify the integrity of the dependencies. While it doesn't show redirections, it can help ensure that the modules have not been tampered with.
go mod verify
7. Use go mod tidy
The go mod tidy command can be used to clean up the go.mod file and ensure that all dependencies are correctly specified.
go mod tidy
By combining these tools and techniques, you can get a better understanding of what is happening when you run go get and check for any redirections or unexpected behavior.