Skip to content

Instantly share code, notes, and snippets.

@mitchallen
Created February 21, 2023 10:28
Show Gist options
  • Save mitchallen/8de25068f7ccbc7c330857a261d247b3 to your computer and use it in GitHub Desktop.
Save mitchallen/8de25068f7ccbc7c330857a261d247b3 to your computer and use it in GitHub Desktop.
Go (Golang) server using the Gin framework
/**
* Author: Mitch Allen
* File: server.go
*/
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "Hello, world!",
})
})
// listen and serve on 0.0.0.0:8080
// on windows "localhost:8080"
// can be overriden with the PORT env var
r.Run()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment