DEV Community

Discussion on: Build Your First Rest API with GO

Collapse
 
mrxinu profile image
Steve Klassen (They/Them)

There's a typo on this line:

log.Fatal(http.ListenAndServe(":8080", r))

Should be:

log.Fatal(http.ListenAndServe(":8080", api))
Collapse
 
moficodes profile image
Mofi Rahman
r := mux.NewRouter()

is my mux router. api is a subrouter on r.

In this example using api instead of r would work.

But if i have other routes on r this would not work.

Collapse
 
mrxinu profile image
Steve Klassen (They/Them)

Oops, good point. I think I hadn't used api yet and it was complaining about that.

Thread Thread
 
moficodes profile image
Mofi Rahman

one of the "best worst" feature of go. :D