If you wish, you can ensure that the compilation step in particular doesn't need/use the network, by first manually fetching the dependencies:
someproject% go get ./... # or 'go mod download'
Next disable network access for the go command, or for the whole system.Then compile:
someproject% go build