There are improvements. Before I keep going on and on about your code I suggest you visit https://github.com/golang/go/wiki/CodeReviewComments which is a nice list of topics to pay attention on.
whenever I see nested if-blocks, I wonder whether they are masking for some boolean math that should be there but it isn’t. The way this block is written, you could remove at least one level of depth.
Ditto. With an additional aspect that you are overwriting the
err passed in functions params with the one gotten by
todos.extractFile. Again, if by this point you don’t want to act on a directory, you can just return nil (I am not sure whether returning nil is the correct thing here. Early on you returned
I haven’t executed the code yet, but I wonder what would happen if the comment looked like this:
How would this if-block behave? https://github.com/asticode/gotodo/blob/master/todo.go#L86-L88 – I see you skip the head of the comment, but does not check the footer.
I do not know whether you read Nystrom’s blog post about variable naming. If you haven’t, it is a very nice read: http://journal.stuffwithstuff.com/2016/06/16/long-names-are-long/
So I am noticing at least one unnecessarily long variable name:
TODOFound (which found is not a todo?)
OK. Now… this is totally a matter of personal opinion, feel free to discard as you will, but I feel using regex to extract assignee is a bit overkill, and probably slow. In the end, you want a very simple thing: find the position of first opening and closing parentheses, and subslice it. It could be accomplished with less, I assume. Check:
And finally, another matter of personal opinion and taste, I believe you could put some effort on the comments, by removing the trivial ones (such: https://github.com/asticode/gotodo/blob/master/todo.go#L37 for example), and improving the ones that matter, like this: https://github.com/asticode/gotodo/blob/master/todo.go#L29
Rob Pike’s once wrote a series of notes on C programming, and dedicated a whole topic about comments. It is also a good read: https://www.lysator.liu.se/c/pikestyle.html
I would highlight:
I tend to err on the side of eliminating comments, for several reasons. […] But I do comment sometimes. Almost exclusively, I use them as an introduction to what follows. Examples: explaining the use of global variables and types (the one thing I always comment in large programs); as an introduction to an unusual or critical procedure; or to mark off sections of a large computation.