gin-gonic / examples

A repository to host examples and tutorials for Gin.

Home Page:https://gin-gonic.com/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I install Gin framework?

undefined0000000 opened this issue · comments

Hi everybody.
I wanna install gin framework with below command,
go get -u github.com/gin-gonic/gin

but I got errors.

go: go.mod file not found in current directory or any parent directory.
        'go get' is no longer supported outside a module.
        To build and install a command, use 'go install' with a version,
        like 'go install example.com/cmd@latest'
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

Go is already installed and I was following steps of Gin doc.
What is solution?

The error message you're receiving indicates that Go modules are now the recommended way to manage dependencies in Go projects, and the go get command is no longer used to install packages outside of a module.

To install the Gin framework using Go modules, follow these steps:

1 - Initialize a Go module for your project if you haven't already. You can do it in your project directory with the following command:

go mod init myproject

Replace "myproject" with the name of your project.

Once you've initialized a Go module, you can use the go get command to install Gin as a dependency within your module. Run the following command:

go get -u github.com/gin-gonic/gin