Home > Software design >  Do I have to install gin framework in every new folder I create in visual Studio code for Golang pro
Do I have to install gin framework in every new folder I create in visual Studio code for Golang pro

Time:06-03

I have already installed gin framework in a different folder on my desktop named Gingo. I am learning how to build a web RESTful API through the Gin framework, by starting the implementation of the backend code that is needed to support our Go Music. But I have created another folder on my desktop for this Go Music named backend, so do I have to install gin framework in this folder as well? The project can be found at https://github.com/gin-gonic/ gin.

CodePudding user response:

The way you use external libraries and frameworks in Go is by using Go modules. Initialise your project by running go mod init name-of-project in the backend folder (or whatever the root folder is for your Go code).

Now, if you want to add gin to your project, you can run go get github.com/gin-gonic/gin, which adds gin to the dependencies of your project (you can see all dependencies in the go.mod file in the project root).

The gin code will be downloaded and placed in the pkg folder in your GOROOT. This way the code has to be downloaded only once, and every time you import it it is simply using the already present code. You do have to add it to the dependencies of your project every time though.

For more information about Go modules: https://zetcode.com/golang/module/

CodePudding user response:

i think you must install in every project, in my opinion because framework on golang just thrid party labrary. but if you want to install on your system you can try this. maybe its can be new journery on your programming

  • Related