🔹 Before Go Modules (pre–Go 1.11)


🔹 With Go Modules (Go 1.11+, default since 1.16)


🔹 When you run go get or go build

  1. Go fetches the source code of the dependency (from GitHub, GitLab, etc.) and places it in $GOPATH/pkg/mod.
  2. Go compiles it into a cached binary form for reuse.
  3. Your project imports from the cache, not from inside your project.

So:

✅ You download the source code, not just the binary.

✅ It goes into a global cache (pkg/mod) instead of your project folder.