New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check for extension and filename first, without load a file content #67
Conversation
Codecov Report
@@ Coverage Diff @@
## master #67 +/- ##
=======================================
Coverage 85.03% 85.03%
=======================================
Files 16 16
Lines 942 942
=======================================
Hits 801 801
Misses 83 83
Partials 58 58 Continue to review full report at Codecov.
|
cli/enry/main.go
Outdated
return nil | ||
var language string | ||
var ok bool | ||
if language, ok = enry.GetLanguageByExtension(path); !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var language string
var ok bool
if language, ok = enry.
could just be replaced by
if language, ok := enry.
or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need the language variable out of the if
scope to append it then to the out[] map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. You can still leave the ok
out then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean something like
var language string
if language, ok := enry...
which would make the need for language
after the if statement explicit while making clear that ok
is only needed inside the if statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I can't, if I don't define the ok
var out the if
too, the :=
in the if statement would define two new variables https://play.golang.org/p/KWI_sbLOaJ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see :S. Then it makes more sense to just define them outside the if statement:
language, ok := enry..
if !ok {
}
Anyway, I'm quite happy with it as it is, just trying to understand go better. Thanks for the explanation!
removed language and ok variables declaration
29e2f0e
to
761029c
Compare
No description provided.