boyter / scc

Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
MIT License
6.8k stars 267 forks source link

refactor: using standard libraries to do file operations #542

Closed apocelipes closed 1 month ago

apocelipes commented 1 month ago

Using standard libraries to get temp path and to do file operations.

This makes the program more simple and safer because standard libraries clean the path and no need to use outside commands.

It also makes the code more portable since not all systems use '/tmp' as its tempfile path (other places for example, '/data/local/tmp'). Many mordern Linux distros also support setting the env varibale '$TMPDIR' to change a program's tempfile path. So using the standard library's getTempDir function is a better idea, it's done all the works for us.

boyter commented 1 month ago

Merging in although I never plan on running the Python script again and the Go code is exclusively running on linux. Thanks for the PR though!