πŸ›’Installation

Just run the following command:

go get -u github.com/indigo-web/indigo@latest

The documentation's current state implies the version v0.17.0

Hello, world!

Create a new package:

mkdir helloworld
cd helloworld
go mod init helloworld
go get -u github.com/indigo-web/indigo@latest

Create main.go with the following code:

package main

import (
  "log"
  
  "github.com/indigo-web/indigo"
  "github.com/indigo-web/indigo/http"
  "github.com/indigo-web/indigo/router/inbuilt"
)

func Hello(request *http.Request) *http.Response {
  return http.String(request, "Hello, world!")
}

func main() {
  r := inbuilt.New()
  r.Get("/", Hello)

  err := indigo.New(":8080").Serve(r)
  if err != nil {
    log.Fatal(err)
  }
}

Run the code:

go run main.go

If everything works just fine, you'll see the text Hello, world! on the http://localhost:8080 page.

Last updated