extend for form type requests
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
2025-07-11 13:46:15 +10:00
parent d658a46a3f
commit 7905823731
4 changed files with 114 additions and 2 deletions

31
main.go
View File

@@ -1,12 +1,15 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
"reflect"
"runtime"
"strconv"
"strings"
"time"
"github.com/iancoleman/orderedmap"
)
@@ -154,3 +157,31 @@ func OrderedToStringSlice(input []interface{}) []string {
return result
}
// prettyPrint comes from https://gist.github.com/sfate/9d45f6c5405dc4c9bf63bf95fe6d1a7c
func prettyPrint(args ...interface{}) {
var caller string
timeNow := time.Now().Format("01-02-2006 15:04:05")
prefix := fmt.Sprintf("[%s] %s -- ", "PrettyPrint", timeNow)
_, fileName, fileLine, ok := runtime.Caller(1)
if ok {
caller = fmt.Sprintf("%s:%d", fileName, fileLine)
} else {
caller = ""
}
fmt.Printf("\n%s%s\n", prefix, caller)
if len(args) == 2 {
label := args[0]
value := args[1]
s, _ := json.MarshalIndent(value, "", "\t")
fmt.Printf("%s%s: %s\n", prefix, label, string(s))
} else {
s, _ := json.MarshalIndent(args, "", "\t")
fmt.Printf("%s%s\n", prefix, string(s))
}
}