This concludes our third article in the series of Go Modules support. Then we need to go to all of the files that have the new import and run the Sync packages of project quick-fix to download and install the newer version of our dependency. In addition to that change, you also need to append /v2 at the end of the import path, so that the upgraded module looks like this: require /dlsniper/demogomodulesmv/v2 v2.0.0Īfter that, a search and replace needs to be done in all the project files to replace the import path and append the major version to it. Upgrading a dependency to a new major version requires a bit more than just going to the go.mod file and changing the version from version v1.6.5 to v2.3.4. We briefly mentioned this in the first article of the series, but it is worthy of a quick recap. Using a dependency with a new major versionĪnother possible scenario is to upgrade a dependency to use a new major version. Push everything using Ctrl+Shift+K on Windows/Linux or Cmd+Shift+K on macOS, and just make sure that you’ve ticked the Push tags checkbox. Type in the new version, e.g., v2.0.0, and that’s it. To tag this commit and create the new version of our module, let’s go to the Log tab of the Version Control tool window, select our commit and use Search Everywhere, Shift+Shift, to find the New Tag… feature. Next, we commit our code using Ctrl+K on Windows/Linux or Cmd+K on macOS. go files for the import, you can use the same rule as above. To module /dlsniper/modulesdemo/v2Īdditionally, if you need to replace all the usages in. If you share your module on Github or other websites, you need to apply the same change as above: module /dlsniper/modulesdemo To prepare our code, we need to ensure that we upgrade the module name in the go.mod file, so let’s do this. When our code is ready to be bumped to a major version, as is the case for breaking API changes, we can use the built-in Version Control tools to help us. Major version upgradingĪs we can see in the Modules Wiki, there are two options for creating a new major version, either use a branch or tag with the v2.x.y or v3.x.y format or use a folder inside the master branch that’s named v2.x.y or v3.x.yįor this article, we’ll use the branch/tag approach. However, upgrading to major versions implies a more complex change, so, let’s look at our options. When doing these upgrades, we don’t need to change anything else in our code. It’s important to keep in mind that we need to give this version a name that is compatible with the SemVer semantics. Then from the Log tab, we select a commit that we want to consider to be the new version, and then we use Search Everywhere, Shift+Shift, type New Tag… and bring up the dialog to name the tag. First, we bring up the Version Control tool window, Alt+9 on Windows/Linux or Option+9 on macOS. Upgrading non-major versions is relatively straightforward. Now, it’s time to do the same for our own code. In our previous posts, we’ve seen how to use dependencies in our code and how to upgrade or downgrade them. Using a dependency with a new major version.Versioning and migrating to a new major version.Visualizing the dependencies of a project.Starting with a new Go Module from scratch.In case you missed the previous posts, here’s a list of articles from the series: In this article, we’ll cover how to version our project and manage the migration to a new major version. This is the third, and final, article from our series on Go Modules.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |