package main import ( "github.com/gin-gonic/gin" "net/http" ) type IndexVM struct { AssetCount int BrandCount int TotalRamCapacity int Brands []string Types []string } func (a *App) getIndex(c *gin.Context) { vm := &IndexVM{} var err error vm.AssetCount, err = a.GetAssetCount() if err != nil { c.AbortWithError(http.StatusInternalServerError, err) return } vm.BrandCount, err = a.GetBrandCount() if err != nil { c.AbortWithError(http.StatusInternalServerError, err) return } vm.TotalRamCapacity, err = a.GetTotalRamCapacity() if err != nil { c.AbortWithError(http.StatusInternalServerError, err) return } vm.Brands, err = a.GetAllBrands() if err != nil { c.AbortWithError(http.StatusInternalServerError, err) return } vm.Types, err = a.GetAllTypes() if err != nil { c.AbortWithError(http.StatusInternalServerError, err) return } c.HTML(http.StatusOK, "index", vm) }