This is the 11th day of my participation in Gwen Challenge

Should you use Go_get to manage packages?

The Go Tool system has a built-in set of related packages for managing versioning, called Modules. The module was introduced in 1.11 and has been available since 1.14.

To create a project that uses modules, just run go mod init. This command creates a go.mod file, which is used to record the dependencies of the project.

go mod init example.com/project
Copy the code

To add, upgrade, or download a dependency, simply run Go Get

go get golang.org/x/text@v03.. 5
Copy the code

You can see more about how to start using Modules in Tutorial: Create a Module.

How do you manage packages in Developing Modules

Use modules to maintain historical compatibility of software packages, please follow the import compatibility rules:

  • If the old package and the new package have the same import path, the new package must be backward compatible with the old package.

The Go 1 compatibility guide is a good reference here, for example: Do not delete exported names, encourage commenting text, and so on. If you need a different function, add a new name instead of changing the old one.

Modules use semantic versioning and semantic import versioning encoding. If you need to break compatibility, modify the module in the new major release. Major version 2 and later modules require a major version suffix as part of the path (e.g. / v2). This preserves the import compatibility rule that packages in different major versions of a module have different paths.

Codify, codify, codifyCopy the code

What’s the difference between new and make?

In short: New mainly allocates memory space. However, make mainly initializes slice, map, and channel types.

Relevant Section of Effective Go for more details.