try debugging the debugging
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-16 17:05:48 +11:00
parent b35d365467
commit 7f43662cbc
2 changed files with 8 additions and 6 deletions

View File

@@ -173,13 +173,11 @@ func SecretsGetAllowed(s *Secret, userId int) ([]UserSecret, error) {
// work around to get the UserId populated in the User field of the struct // work around to get the UserId populated in the User field of the struct
r.User.UserId = r.UserUserId r.User.UserId = r.UserUserId
/* // For debugging purposes
// For debugging purposes debugPrint := utils.PrintStructContents(&r, 0)
debugPrint := utils.PrintStructContents(&r, 0) log.Println(debugPrint)
log.Println(debugPrint)
log.Printf("SecretsGetAllowed performed debug print\n") log.Printf("SecretsGetAllowed performed debug print\n")
*/
// Append the secrets to the query output, don't decrypt the secrets (we didn't SELECT them anyway) // Append the secrets to the query output, don't decrypt the secrets (we didn't SELECT them anyway)
//secretResults = append(secretResults, r) //secretResults = append(secretResults, r)

View File

@@ -2,6 +2,7 @@ package utils
import ( import (
"fmt" "fmt"
"log"
"reflect" "reflect"
"strings" "strings"
) )
@@ -21,6 +22,8 @@ func PrintStructContents(s interface{}, indentLevel int) string {
field := val.Field(i) field := val.Field(i)
fieldType := typ.Field(i) fieldType := typ.Field(i)
log.Printf("PrintStructContents field '%s' (%T)\n", field, fieldType)
indent := strings.Repeat("\t", indentLevel) indent := strings.Repeat("\t", indentLevel)
result.WriteString(fmt.Sprintf("%s%s: ", indent, fieldType.Name)) result.WriteString(fmt.Sprintf("%s%s: ", indent, fieldType.Name))
@@ -29,6 +32,7 @@ func PrintStructContents(s interface{}, indentLevel int) string {
result.WriteString("\n") result.WriteString("\n")
result.WriteString(PrintStructContents(field.Interface(), indentLevel+1)) result.WriteString(PrintStructContents(field.Interface(), indentLevel+1))
default: default:
log.Printf("%v\n", field.Interface())
result.WriteString(fmt.Sprintf("%v\n", field.Interface())) result.WriteString(fmt.Sprintf("%v\n", field.Interface()))
} }
} }