diff options
author | Emile <hanemile@protonmail.com> | 2019-11-01 19:20:32 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-11-01 19:20:32 +0100 |
commit | 530997eeec95ac5fa99f3494cfb055138b45fc03 (patch) | |
tree | 4788a5bfe8b3ed68b0b7b92be62c11649fefe22d /src | |
parent | 9c3d2c96d2e67953ce084182c3b83199106a2923 (diff) |
print foo
Diffstat (limited to 'src')
-rw-r--r-- | src/printer.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/printer.go b/src/printer.go new file mode 100644 index 0000000..7bc9beb --- /dev/null +++ b/src/printer.go @@ -0,0 +1,42 @@ +package main + +import "fmt" + +func printResponses(printChannel chan Response) { + var i int + for { + // read a response from the printChannel for further usage + response := <-printChannel + + // define a postfix: a string attached to the end of all printed + // string set in the section filtering the status code cases + var postfix string + var prefix string + + // define what color should be used to print the individual status + // codes + var statusCode string + + switch response.StatusCode { + case 200: + + // jump to the beginning of the line, clear the line, then print + // the response + prefix = "\r\033[K" + statusCode = green(fmt.Sprintf("%d", response.StatusCode)) + postfix = "\n" + + case 404: + + // print the status code, then clear the line and jump back to + // the beginning + statusCode = red(fmt.Sprintf("%d", response.StatusCode)) + postfix = "\033[K\r" + + } + + // print the foo + fmt.Printf("%s%.7d: %s %s%s", prefix, i, statusCode, response.FuzzWord, postfix) + i++ + } +} |