Setup Go project

This commit is contained in:
Robin Dittmar
2026-07-01 11:35:56 +02:00
parent 4c13eba9a1
commit 641f25650f
2 changed files with 37 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
type ApiResponse struct {
Version int `json:"version"`
Path string `json:"path"`
}
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
resp := ApiResponse{Path: "/v1", Version: 1}
b, err := json.Marshal(resp)
if err != nil {
log.Println(err)
return
}
_, err = w.Write(b)
if err != nil {
log.Println(err)
return
}
})
fmt.Println("Listening on localhost:8080")
log.Fatal(http.ListenAndServe("localhost:8080", nil))
}
+3
View File
@@ -0,0 +1,3 @@
module github.com/robindittmar/dttmr-api
go 1.26