GO111Module environment variable?

 At very first go release we do not have any kind of package versioning.

That means if you import any third party package then it always gets its latest version and stores in its GOPATH.

Why it is a problem?

When developers build the applications , they may use older version or latest version of a package at the time of development.

When  a package gets updated then functions behavior changes or the inputs that a updated function may require gets changed , this leads to application breakdown.

Why GO111Module is named like that?

It is named after the version of the go release 1.11 ,from this version go designers included version controlling for packages.

What does GO111Module environment variable is used for?

GO111Module env variable has 3 values:

  • auto
  • on
  • off

the default value depends on version of go you are using and it also depends on where you project is located, whether in GOPATH or not, whether the working directory contains go.mod file or not.

In the latest versions of go ,where-ever your project may exist, if you have a go.mod file then GO111Module is "on" this implies that the package references will be taken from the go.mod file.

you can just use:

go install packagelocation@version

By default go installs latest version of package:

go install packagelocation

or

go install packagelocation@latest 

Comments

Popular posts from this blog

What is go.mod?

What is go package?