oh, I really didn't introduce that so well...

I fixed the issue about multiple init/main functions by setting it to count 
how many it finds and just leaving them where they are if there is more 
than one (they will just end up in arbitrary order next to each other 
within the func block for this case). 

I also fixed the stdin for stdoutput, now you can go 'cat file.go|tidy 
stdin' and the result will print on the terminal, so you could chain it to 
other processing commands afterwards.

It's very simple thing but I think it's going to be a huge help for me with 
handling large codebases and speeding up the process of logically dividing 
into files, and potentially, it may make it easier to see that a package 
should be split or merged (if the circular imports don't get you first).

On Friday, 15 February 2019 22:08:04 UTC+1, Louki Sumirniy wrote:
>
> I have written a small source code processing tool which does something 
> that I personally think that gofmt should do. It's called tidy, and it's 
> hiding inside the embryonic attempt at a 'deal with all those irritating 
> application setup startup stuff' project here:
>
> https://github.com/l0k1verloren/skele/tree/master/cmd/tidy
>
> All it does is slice a source file up into the root level sections, 
> package, imports, type, const, var, func. All of the groups are sorted by 
> alphabetical order based on the content of their key line (line starting 
> with root level keyword), the 'main' and 'init' functions are pushed to the 
> top of the block of functions.
>
> In theory, it is possible to take an entire package, a whole folder 
> containing all the same package name. It only will pick up one of the 
> package header parts, I'm not sure about imports, I think gofmt 
> automatically consolidates multiple anyway, but yeah it will also stumble 
> over those init blocks too for this. I will probably need to fix that since 
> exactly this merging of sources is one of my intended uses).
>
> I don't know why it took me so bleedin long to write it, it was funny, I 
> wrote something that worked about 90% in about an hour and then it took 2 
> days to redo it, I kept overcomplicating things (ahaha, well, read the 
> prose, know the code :)
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to