app
A simple Go web server application that returns the hostname. This app demonstrates basic Go web development and logging. Check it out!
Go App
This is a simple Go web server application. It demonstrates basic Go web development, including handling HTTP requests and using the logrus library for structured logging.
Source Code
package main
import (
"net/http"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetFormatter(&log.JSONFormatter{})
log.Info("starting server")
http.HandleFunc("/", hostnameHandler)
http.ListenAndServe("0.0.0.0:8080", nil)
}
func hostnameHandler(w http.ResponseWriter, r *http.Request) {
log.SetFormatter(&log.JSONFormatter{})
log.WithFields(log.Fields{"health": "ok"}).Info("service is healthy")
}
Further Reading
To learn more about Go web development, check out these resources: