![]() If we want to use version 0.8.0 instead, we can edit the go.mod file manually, which will trigger a refresh of the dependencies and use the expected version. This will run the required Go commands to download and install the desired version of our dependency.Īt the time of writing, /pkg/errors is at version 0.8.1, so this version will be installed as we did not specify anything in our go.mod file. To import this dependency, write the import statement “`import “/pkg/errors”“` and use the Sync packages of /JetBrains/go-samples quick-fix on it. We can use the Simple Application type instead of Empty File to move past the boilerplate part.Īfter writing a small HelloWorld function, let’s say we want to handle errors in our code using the popular /pkg/errors package. Next, creating a Go file is done as before, so nothing changes here. For example, we’ll publish this under /JetBrains/go-samples so others can use the import statement “`import “/JetBrains/go-samples”“` in their code. We can edit the file to change the module name to better suit our needs. While Go 1.10 with the special vgo binary installed can be used, this is not recommended as vgo is not updated as frequently to be on par with the Go releases and might have an unforeseen impact in a mixed Go versions environment.įinally, we can use the Proxy field to specify if we want to download the Go Modules (or packages) directly from the Internet (default setting), or via a proxy system such as Athens or JFrog’s Go Registry in case you want to store the dependencies in a central place for everyone in the team to have access to the same versions in a better-managed environment.Īfter the project is created, we can see that it already contains a go.mod file. We can then specify the location of the project, which can now be set outside of the GOPATH, to any directory in your system.Įnsure that GOROOT points to a Go SDK which is 1.11 or newer. ![]() Then choose Go Modules (vgo) as the project type. ![]() In this blog post, we’ll explore how to work with Go Modules when creating new Go projects or working with existing ones.įirst, let’s create a new project by selecting New Project from the Welcome Screen. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |