{"action":"created","issue":{"url":"https://api.github.com/repos/davecheney/httpstat/issues/45","repository_url":"https://api.github.com/repos/davecheney/httpstat","labels_url":"https://api.github.com/repos/davecheney/httpstat/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/davecheney/httpstat/issues/45/comments","events_url":"https://api.github.com/repos/davecheney/httpstat/issues/45/events","html_url":"https://github.com/davecheney/httpstat/issues/45","id":179067748,"number":45,"title":"Increase separation of concerns in colour formatting code","user":{"login":"davecheney","id":7171,"avatar_url":"https://avatars.githubusercontent.com/u/7171?v=3","gravatar_id":"","url":"https://api.github.com/users/davecheney","html_url":"https://github.com/davecheney","followers_url":"https://api.github.com/users/davecheney/followers","following_url":"https://api.github.com/users/davecheney/following{/other_user}","gists_url":"https://api.github.com/users/davecheney/gists{/gist_id}","starred_url":"https://api.github.com/users/davecheney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecheney/subscriptions","organizations_url":"https://api.github.com/users/davecheney/orgs","repos_url":"https://api.github.com/users/davecheney/repos","events_url":"https://api.github.com/users/davecheney/events{/privacy}","received_events_url":"https://api.github.com/users/davecheney/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/davecheney/httpstat/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/davecheney/httpstat/labels/help%20wanted","name":"help wanted","color":"128A0C"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/davecheney/httpstat/milestones/1","html_url":"https://github.com/davecheney/httpstat/milestones/Stable%20release","labels_url":"https://api.github.com/repos/davecheney/httpstat/milestones/1/labels","id":2026564,"number":1,"title":"Stable release","description":"Let's shoot for a 1.0 release.\r\n\r\nAnything tagged with this milestone represents a feature to be supported for the life of 1.0 (which is probably going to be the only release this project sees in the the medium term). \r\n\r\nAnything not tagged for this milestone may be added in a following point 1.x point release.","creator":{"login":"davecheney","id":7171,"avatar_url":"https://avatars.githubusercontent.com/u/7171?v=3","gravatar_id":"","url":"https://api.github.com/users/davecheney","html_url":"https://github.com/davecheney","followers_url":"https://api.github.com/users/davecheney/followers","following_url":"https://api.github.com/users/davecheney/following{/other_user}","gists_url":"https://api.github.com/users/davecheney/gists{/gist_id}","starred_url":"https://api.github.com/users/davecheney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecheney/subscriptions","organizations_url":"https://api.github.com/users/davecheney/orgs","repos_url":"https://api.github.com/users/davecheney/repos","events_url":"https://api.github.com/users/davecheney/events{/privacy}","received_events_url":"https://api.github.com/users/davecheney/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":2,"state":"open","created_at":"2016-09-25T02:27:34Z","updated_at":"2016-09-25T05:21:17Z","due_on":"2017-09-03T00:00:00Z","closed_at":null},"comments":1,"created_at":"2016-09-25T04:50:14Z","updated_at":"2016-09-25T05:59:03Z","closed_at":null,"body":"Currently the formatting of coloured output is handled before passing the string to `fmt.Printf`. As an exercise I would like to see if it is possible to make the type of the argument passed to `fmt.Printf` implement `fmt.Formatter` and handle the colorisation of the output at the point at which it is printed.\r\n\r\n_note to implementors_: this has no impact on the performance or memory usage of this program, in fact it'll probably make it infinitesimally slower and larger. I'm mainly interested in exploring this to improve the separation of concerns between the code that prepares the output, and the code that colourises it."},"comment":{"url":"https://api.github.com/repos/davecheney/httpstat/issues/comments/249404602","html_url":"https://github.com/davecheney/httpstat/issues/45#issuecomment-249404602","issue_url":"https://api.github.com/repos/davecheney/httpstat/issues/45","id":249404602,"user":{"login":"ChrisHines","id":1060711,"avatar_url":"https://avatars.githubusercontent.com/u/1060711?v=3","gravatar_id":"","url":"https://api.github.com/users/ChrisHines","html_url":"https://github.com/ChrisHines","followers_url":"https://api.github.com/users/ChrisHines/followers","following_url":"https://api.github.com/users/ChrisHines/following{/other_user}","gists_url":"https://api.github.com/users/ChrisHines/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisHines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisHines/subscriptions","organizations_url":"https://api.github.com/users/ChrisHines/orgs","repos_url":"https://api.github.com/users/ChrisHines/repos","events_url":"https://api.github.com/users/ChrisHines/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisHines/received_events","type":"User","site_admin":false},"created_at":"2016-09-25T05:59:03Z","updated_at":"2016-09-25T05:59:03Z","body":"```go\r\ntype Green string\r\n\r\nfunc (g Green) Format(f fmt.State, c rune) { ... }\r\n\r\ngreenGreeting := Green(\"hello\") + \" world\"\r\nfmt.Println(greenGreeting)\r\n```\r\nWhat part of the output from the above code should be green? It seems like the intent is that only \"hello\" would be green, but `greenGreeting` has type `Green`, so the whole message would get formatted by `Green.Format` which would not be able to tell what portion should be green.\r\n\r\nAlso, the following wouldn't work, and this inconvenience seems to dilute the value of the approach somewhat.\r\n```go\r\n\r\ntype Green string\r\n\r\ntype Blue string\r\n\r\nfunc main() {\r\n\tgreeting := Green(\"hello\") + Blue(\" world\") // invalid operation: Green(\"hello\") + Blue(\" world\") (mismatched types Green and Blue)\r\n\tfmt.Printf(greeting)\r\n}\r\n```"}}
{"actor":{"display_login":"ChrisHines"}}