goyamlbackendgo-cobrago-build

What does this command do 'GOFLAGS=-mod=mod'?


I am trying to make a Taskfile.yml file for building go application, but I can't quite understand the need of "GOFLAGS=-mod=mod" command before go build main.go.

reference: https://dev.to/aurelievache/learning-go-by-examples-part-3-create-a-cli-app-in-go-1h43


Solution

  • So there are two things here

    Therefore

    GOFLAGS="-mod=mod" go build main.go
    

    is equivalent to

    go build -mod=mod main.go