From ca6003af1a7e1adb7d45879c2d5038bc05c2bb1a Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Fri, 2 Aug 2019 15:07:53 +0200 Subject: Migrate to modules, refactor Makefile and use Travis for CI - migrate to Go modules and remove vendor - refactor Makefile - add version package and store version - split extras from the rest - use travis for CI Change-Id: I81b35220653b0f7c9a0fcdd4c527d691ec1e96c1 Signed-off-by: Ondrej Fabry --- vendor/github.com/bennyscetbun/jsongo/print.go | 74 -------------------------- 1 file changed, 74 deletions(-) delete mode 100644 vendor/github.com/bennyscetbun/jsongo/print.go (limited to 'vendor/github.com/bennyscetbun/jsongo/print.go') diff --git a/vendor/github.com/bennyscetbun/jsongo/print.go b/vendor/github.com/bennyscetbun/jsongo/print.go deleted file mode 100644 index 6869918..0000000 --- a/vendor/github.com/bennyscetbun/jsongo/print.go +++ /dev/null @@ -1,74 +0,0 @@ -package jsongo - -import ( - "fmt" - "regexp" - "strings" -) - -//Thanks https://github.com/chuckpreslar/inflect for the UpperCamelCase - -// Split's a string so that it can be converted to a different casing. -// Splits on underscores, hyphens, spaces and camel casing. -func split(str string) []string { - // FIXME: This isn't a perfect solution. - // ex. WEiRD CaSINg (Support for 13 year old developers) - return strings.Split(regexp.MustCompile(`-|_|([a-z])([A-Z])`).ReplaceAllString(strings.Trim(str, `-|_| `), `$1 $2`), ` `) -} - -// UpperCamelCase converts a string to it's upper camel case version. -func UpperCamelCase(str string) string { - pieces := split(str) - - for index, s := range pieces { - pieces[index] = fmt.Sprintf(`%v%v`, strings.ToUpper(string(s[0])), strings.ToLower(s[1:])) - } - - return strings.Join(pieces, ``) -} - -func (that *JSONNode) printValue(indentlevel int, indentchar string) { - fmt.Printf(" %T ", that.Get()) -} - -func (that *JSONNode) printMap(indentlevel int, indentchar string) { - fmt.Printf(" struct {\n") - for key := range that.m { - printfindent(indentlevel+1, indentchar, "%s", UpperCamelCase(key)) - that.m[key].print(indentlevel+1, indentchar) - fmt.Printf(" `json:\"%s\"`\n", key) - } - printfindent(indentlevel, indentchar, "}") -} - -func (that *JSONNode) printArray(indentlevel int, indentchar string) { - if len(that.a) == 0 { - fmt.Printf(" []interface{} ") - return - } - fmt.Printf(" [] ") - for key := range that.a { - that.a[key].print(indentlevel+1, indentchar) - break - } -} - -//DebugProspect Print all the data the we ve got on a node and all it s children -func (that *JSONNode) print(indentlevel int, indentchar string) { - switch that.t { - case TypeValue: - that.printValue(indentlevel, indentchar) - case TypeMap: - that.printMap(indentlevel, indentchar) - case TypeArray: - that.printArray(indentlevel, indentchar) - case TypeUndefined: - printfindent(indentlevel, indentchar, "Is of Type: TypeUndefined\n") - } -} - -//Print Print all the data the we ve got on a node and all it s children as a go struct :) (FOR DEV PURPOSE) -func (that *JSONNode) Print() { - that.print(0, "\t") - fmt.Printf("\n") -} -- cgit 1.2.3-korg