-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
689 additions
and
596 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @n3m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
language: go | ||
go: | ||
- master | ||
script: | ||
- go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package pprnt | ||
|
||
import "testing" | ||
|
||
func Test_Deprecated_Print(t *testing.T) { | ||
|
||
Deprecated.CleanMap(map[string]interface{}{}) | ||
|
||
Deprecated.CleanArray([]interface{}{}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= | ||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= | ||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= | ||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | ||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= | ||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package pprnt | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"strings" | ||
) | ||
|
||
var indentation int = 2 | ||
|
||
var lvl string = strings.Repeat("\t", indentation) | ||
|
||
func _CreateLevelString() string { | ||
return strings.Repeat(lvl, _state.Level) | ||
} | ||
|
||
func _ProcessArchitecture(arg interface{}, key *string, endChar *string) string { | ||
value := reflect.ValueOf(arg) | ||
|
||
if arg == nil { | ||
return _PrintNil(arg, key, endChar) | ||
} | ||
|
||
switch reflect.TypeOf(arg).Kind() { | ||
|
||
case reflect.Slice, reflect.Array: | ||
return _PrintSliceOrArray(reflect.Indirect(value).Interface(), key, endChar) | ||
case reflect.Map: | ||
return _PrintMap(reflect.Indirect(value).Interface(), key, endChar) | ||
case reflect.Struct: | ||
return _PrintStruct(reflect.Indirect(value).Interface(), key, endChar) | ||
// case reflect.Chan: | ||
// case reflect.Interface: | ||
case reflect.Ptr: | ||
newValue := value.Elem() | ||
newValue = reflect.Indirect(newValue) | ||
return _ProcessArchitecture(newValue.Interface(), key, endChar) | ||
// case reflect.UnsafePointer: | ||
// case reflect.Uintptr: | ||
} | ||
|
||
return _PrintPrimitive(reflect.Indirect(value).Interface(), key, endChar) | ||
} | ||
|
||
func _PrintPrimitive(arg interface{}, key *string, endChar *string) string { | ||
switch reflect.TypeOf(arg).Kind() { | ||
case reflect.String: | ||
return _PrintString(arg, key, endChar) | ||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: | ||
return _PrintInt(arg, key, endChar) | ||
case reflect.Bool: | ||
return _PrintBoolean(arg, key, endChar) | ||
case reflect.Float32, reflect.Float64: | ||
return _PrintFloat(arg, key, endChar) | ||
default: | ||
|
||
fmt.Printf("[!!] %+v\n", arg) | ||
return fmt.Sprintf("%+v\n", arg) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package pprnt | ||
|
||
const ( | ||
//ColorReset ... | ||
ColorReset string = "\033[0m" | ||
//ColorRed ... | ||
ColorRed string = "\033[31m" //Not supported or nil | ||
//ColorGreen ... | ||
ColorGreen string = "\033[32m" //String | ||
//ColorYellow ... | ||
ColorYellow string = "\033[33m" //Keys | ||
//ColorBlue ... | ||
ColorBlue string = "\033[34m" //Bool | ||
//ColorPurple ... | ||
ColorPurple string = "\033[35m" //Int floats | ||
//ColorCyan ... | ||
ColorCyan string = "\033[36m" //Brackets or Corch | ||
//ColorGray ... | ||
ColorGray string = "\033[37m" | ||
//ColorWhite ... | ||
ColorWhite string = "\033[97m" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package pprnt | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
const formatString string = "\"%+v\"" | ||
const formatInt string = "%d" | ||
const formatBoolean string = "%t" | ||
const formatNil string = "%s" | ||
const formatFloat string = "%+v" | ||
|
||
func _PrintString(elem interface{}, key *string, endChar *string) string { | ||
return _DoPrintPrimitive(formatString, key, endChar, elem) | ||
} | ||
|
||
func _PrintInt(elem interface{}, key *string, endChar *string) string { | ||
return _DoPrintPrimitive(formatInt, key, endChar, elem) | ||
} | ||
|
||
func _PrintBoolean(elem interface{}, key *string, endChar *string) string { | ||
return _DoPrintPrimitive(formatBoolean, key, endChar, elem) | ||
} | ||
|
||
func _PrintNil(elem interface{}, key *string, endChar *string) string { | ||
return _DoPrintPrimitive(formatNil, key, endChar, "<nil>") | ||
} | ||
|
||
func _PrintFloat(elem interface{}, key *string, endChar *string) string { | ||
return _DoPrintPrimitive(formatFloat, key, endChar, elem) | ||
} | ||
|
||
func _DoPrintPrimitive(format string, key *string, endChar *string, elem interface{}) string { | ||
lvlStr := _CreateLevelString() | ||
|
||
strToPrint := "" | ||
|
||
if key != nil { | ||
strToPrint += lvlStr + "\"" + *key + "\"" + ": " | ||
key = nil | ||
} else { | ||
strToPrint += lvlStr | ||
} | ||
|
||
strToPrint += fmt.Sprintf(format, elem) | ||
|
||
if _state.Level > 0 { | ||
strToPrint += "," | ||
} | ||
|
||
if endChar != nil { | ||
strToPrint += *endChar | ||
} else { | ||
strToPrint += "\n" | ||
} | ||
|
||
fmt.Print(strToPrint) | ||
return fmt.Sprint(strToPrint) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package pprnt | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
) | ||
|
||
func _PrintSpecialInitSetup(str, lvlStr string, key *string, initSetupChar string) (string, *string) { | ||
if key != nil { | ||
str += lvlStr + "\"" + *key + "\"" + ": " | ||
key = nil | ||
} else { | ||
str += lvlStr | ||
} | ||
|
||
str += initSetupChar + "\n" | ||
fmt.Print(str) | ||
|
||
return str, key | ||
} | ||
|
||
func _PrintSpecialEndSetup(str, lvlStr string, endChar *string, endSetupChar string) string { | ||
finalStrToPrint := lvlStr + endSetupChar | ||
if _state.Level > 0 { | ||
finalStrToPrint += "," | ||
} | ||
|
||
if endChar != nil { | ||
finalStrToPrint += *endChar | ||
} else { | ||
finalStrToPrint += "\n" | ||
} | ||
|
||
return finalStrToPrint | ||
} | ||
|
||
func _PrintSliceOrArray(arg interface{}, key *string, endChar *string) string { | ||
str := "" | ||
lvlStr := _CreateLevelString() | ||
|
||
// Initial Setup | ||
str, key = _PrintSpecialInitSetup(str, lvlStr, key, "[") | ||
_state.Level++ | ||
|
||
// Processing each element | ||
items := reflect.ValueOf(arg) | ||
items = reflect.Indirect(items) | ||
for i := 0; i < items.Len(); i++ { | ||
item := items.Index(i) | ||
item = reflect.Indirect(item) | ||
|
||
str += _ProcessArchitecture(item.Interface(), key, endChar) | ||
} | ||
|
||
// Final Setup | ||
_state.Level-- | ||
finalStrToPrint := _PrintSpecialEndSetup(str, lvlStr, endChar, "]") | ||
str += finalStrToPrint | ||
fmt.Print(finalStrToPrint) | ||
return str | ||
} | ||
|
||
func _PrintMap(arg interface{}, key *string, endChar *string) string { | ||
lvlStr := _CreateLevelString() | ||
str := "" | ||
|
||
// Initial Setup | ||
str, _ = _PrintSpecialInitSetup(str, lvlStr, key, "{") | ||
_state.Level++ | ||
|
||
// Processing each element | ||
mapObj := reflect.ValueOf(arg) | ||
for _, key := range mapObj.MapKeys() { | ||
value := mapObj.MapIndex(key).Interface() | ||
|
||
str += _ProcessArchitecture(value, | ||
GetStringAdddress(key.String()), | ||
endChar) | ||
} | ||
|
||
// Final Setup | ||
_state.Level-- | ||
finalStrToPrint := _PrintSpecialEndSetup(str, lvlStr, endChar, "}") | ||
str += finalStrToPrint | ||
fmt.Print(finalStrToPrint) | ||
return str | ||
} | ||
|
||
func _PrintStruct(arg interface{}, key *string, endChar *string) string { | ||
|
||
lvlStr := _CreateLevelString() | ||
str := "" | ||
|
||
// Initial Setup | ||
str, _ = _PrintSpecialInitSetup(str, lvlStr, key, "{") | ||
_state.Level++ | ||
|
||
// Processing each element | ||
structValues := reflect.ValueOf(arg) | ||
structValues = reflect.Indirect(structValues) | ||
|
||
for j := 0; j < structValues.NumField(); j++ { | ||
str += _ProcessArchitecture(structValues.Field(j).Interface(), | ||
GetStringAdddress(structValues.Type().Field(j).Name), | ||
endChar) | ||
} | ||
|
||
// Final Setup | ||
_state.Level-- | ||
finalStrToPrint := _PrintSpecialEndSetup(str, lvlStr, endChar, "}") | ||
str += finalStrToPrint | ||
fmt.Print(finalStrToPrint) | ||
return str | ||
} |
Oops, something went wrong.