I'm working on modernizing Rosetta Code's infrastructure. Starting with communications. Please accept this time-limited open invite to RC's Slack.. --Michael Mol (talk) 20:59, 30 May 2020 (UTC)

User talk:Dchapes

From Rosetta Code

Go Sum digits task[edit]

[This is in relation to Sum digits of an integer, id=188562. —dchapes]

I don't know what was going on with the non-working tests. Good catch there. Also I don't know why I thought it was worth the complexity to share a function with Digital root. This seems beyond the scope of either task. I'd be in favor of converting Sum digits to a main program like most of the other Go solutions. —Sonia (talk) 03:17, 3 September 2014 (UTC)

Sounds good. I might do that soon-ish but it's not a high priority for me. Of course, feel free to make such changes yourself (and take the opportunity to clean up or simplify my stuff) if you're so inclined.
It's quite possible the old test may have worked pre-Go 1.0. The only actual breakage was that the test function was testSum rather than TestSum and was not found or run by current go test invocations. Although I also chose to also change it from using package digit_test black box test style (which other than for Example* "tests" I'm not a fan of), that wasn't an actual problem.
It's kind of sad that the way sites like RosettaCode are done make it hard to do the "right thing" for languages like Go (multiple files, with extra test code files and separate main "demo programs", proper revision control, etc). Among other things it doesn't let us show off one of the great aspects of Go (IMO) which is the testing and build infrastructure.
Actually, on that note, does it makes any sense (and is there a reasonably nice way on RosettaCode) to provide extra non-example test files? Something that doesn't show up directly on the example page (it would be clutter and take away from the purpose of simplified examples IMO). E.g. for some of the examples I've submitted I have an associated non-trivial *_test.go file and if someone else wanted to cleanup/change/add-to the example later it might be convenient for them if they had that too. —dchapes (talk | contribs) 15:15, 3 September 2014 (UTC)
You can always add subpages. If you just go to http://rosettacode.org/wiki/task_name/Go/whatever_test.go you can create the page, add the text of your test file, and then add a link on the main Go example. We already make subpages for long examples (e.g. Pythagorean triples/Java/Brute force primitives) so it's not out of the ordinary. Putting links on the task pages to separate pages with more detailed information sounds like a great way to let people dig deeper if they so choose. --Mwn3d (talk) 15:45, 3 September 2014 (UTC)

Go Secure temporary file task.[edit]

Should we close the file too? I think it gets closed when the process ends but I'm with the people who don't like to rely on that. It could either be a separate defer or we could defer a literal with both the Close and Remove.

To get fancy we could put the existing code in a function, have that function stat the file, return the file name to main, then have main stat the file and show that it's been removed. ...To get even fancier we could fire off a thousand concurrent functions and check all errors to show there are no collisions. —Sonia (talk) 19:20, 29 December 2014 (UTC)

Not closing the file was a silly oversight. Also note that (at least on sane OSes) if the file doesn't need to be re-opened the file could be immediately removed while still open and being read+written to avoid the case where sudden termination (e.g. SIGINT) prevents simple cleanup/removal.
However, I purposelessly avoided making the example too complicated, I actually liked the original that effectively just pointed out the relevant function, except that the function is explicitly documented as requiring the caller to remove the file so I felt adding that was important. I also wanted to demonstrate that the argument was used as a prefix for a random name and was put into a reasonable directory by default. —dchapes (talk | contribs) 20:06, 29 December 2014 (UTC)
Nice, except... log.Fatal terminates without running deferred functions. I'd be okay with just changing log.Fatal(err) to log.Print(err); return. —Sonia (talk) 22:34, 29 December 2014 (UTC)