26
loading...
This website collects cookies to deliver better user experience
go get
command. Specify the package needed and Go will add it to the module as a dependency. Before we get to that part let's look at how to initialize module in Go.go.mod
file. This will contain details about our modulego mod init {modulename}
command to initialize your modulego mod init helloworld
go.mod
file with the module name "helloworld"go get
command is the standard way of adding dependencies to your modules.go get {package_name}
go get github.com/gofiber/fiber/v2
package main
import "github.com/gofiber/fiber/v2"
func main() {
// Staring a server
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello from fiber")
})
app.Listen(":3000")
}
go mod tidy -v
command to remove any unused packagepackage main
func main() {
// Staring a server
}
go mod tidy -v
Output:
unused github.com/gofiber/fiber
go.mod
will also be updated to remove the dependency.go mod init {packagename}
go get {packagename}
go mod tidy -v
command