https://github.com/project-empower/randomart-image
It's a first stab at anything Go. I'm from C++. Would like a kind hearted soul to tell me how horrible it is...constructively
Edit: Thanks for the input! I applied corrections based on input, including gomalinter
评论:
jehaby:
Crazy__Eddie:You might want to take a look at https://github.com/alecthomas/gometalinter
tclineks:This is great! Thanks!
Looks pretty good but there are some things to improve:
- snake case is not idiomatic for function names
- you aren't checking https://godoc.org/bufio#Scanner.Err
- the use of a channel for the scanner is IMO suspect
- you're not returning a non-zero exit code on line 70
- you're ignoring the possible error from png.Encode (errcheck linter should tell you this)
- it looks like the code hasn't been run through gofmt/goimports (some whitespace oddities)
- you have some commented out code in there
- the output filename should be a parameter (and probably default to stdout -- https://godoc.org/github.com/campoy/tools/imgcat could be a fun addition!)
that's a mix of idiom, error handling, tooling, and style nits -- I hope helpful and gently enough delivered! Welcome to go!
Crazy__Eddie:0xjnml:the use of a channel for the scanner is IMO suspect
Yeah, that was not necessary. I was playing with the idea of "reactive" and my little bit of knowledge there is "functional reactive programming". Channels seemed like Go's react like crap. It's definitely overkill.
Thanks for the feedback!
:Quite good for a first stab. Please use gofmt before committing.
Crazy__Eddie:[deleted]
Ooh. Forgot about that thing. I saw it and meant to use it. Thanks!
