I ran the ‘Hello World’ code mentioned in the official GoFiber document document but got the following error:
$ go run main.go
# github.com/gofiber/fiber
/home/user/go/pkg/mod/github.com/gofiber/[email protected]/path.go:175:21: undefined: utils.GetTrimmedParam
The code that I ran was:
package main
import "github.com/gofiber/fiber"
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) {
c.Send("Hello, World!")
})
app.Listen(3000)
}
What I did before running this code was as follows:
go mod init main
$ go get -u github.com/gofiber/fiber
$ go get -u github.com/gofiber/fiber/v2
go: added github.com/gofiber/fiber/v2 v2.52.5
go: added github.com/mattn/go-runewidth v0.0.15
go: added github.com/rivo/uniseg v0.4.7
$ go get -u github.com/gofiber/fiber/v3
go: added github.com/gofiber/fiber/v3 v3.0.0-beta.3
go: added github.com/gofiber/utils/v2 v2.0.0-beta.5
go mod tidy
Can anyone let me know what I am doing wrong?
1
I try to do this example. Its success. I guess your init mod
method wrong?Dont need to get
, just go mod tidy
.
user24491917 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The problem was with this:
$ go get -u github.com/gofiber/fiber
$ go get -u github.com/gofiber/fiber/v2
$ go get -u github.com/gofiber/fiber/v3
I shouldn’t have had to add different versions of gofiber as dependencies, especially the v1 which is now no longer supported.
Problem was solved after I deleted the go.mod file and tried again with only v2 of GoFiber.
1