Removed printlns and ran file through gofmt.

This commit is contained in:
al2f
2024-01-25 12:31:19 +10:30
parent 386168ebcb
commit b4c9ea68a0
+12 -15
View File
@@ -1,12 +1,12 @@
package pages
import (
"fmt"
"github.com/tidwall/gjson"
"log"
"net/http"
"os"
"fmt"
"github.com/tidwall/gjson"
"codeberg.org/gothub/gothub/utils"
"github.com/gocolly/colly"
"github.com/gofiber/fiber/v2"
@@ -56,34 +56,31 @@ func DirView(c *fiber.Ctx) error {
}
sc := colly.NewCollector(colly.AllowedDomains("github.com"), colly.UserAgent(UserAgent))
sc.OnResponse(func(r *colly.Response) {
jsonMess := string(r.Body)
dirList := gjson.Get(jsonMess, "payload.tree.items")
dirList.ForEach(func(i, e gjson.Result) bool {
var FileType string
if(e.Get("contentType").Str == "directory"){
if e.Get("contentType").Str == "directory" {
FileType = "dir"
} else {
FileType = "file"
}
dirFilesArray = append(dirFilesArray, DirFiles{
Name: e.Get("name").Str,
// Path is the path to the file/folder from the repository root
Path: e.Get("path").Str,
Type: FileType,
Branch: Scrape.Branch,
Path: e.Get("path").Str,
Type: FileType,
Branch: Scrape.Branch,
Fullname: Scrape.Fullname,
})
fmt.Println(dirFilesArray)
return true //keep iterating
})
fmt.Println(dirList)
})
sc.Visit("https://github.com/" + c.Params("user") + "/" + c.Params("repo") + "/tree/" + c.Params("branch") + "/" + c.Params("+"))