Brian, thanks! Here's the playground link: https://play.golang.org/p/Ef8D4CF-kKD
For the errors in lines 14-19, what other failures do you see needing to be handled? I'm still not comprehending how to check for "isReadable()", but that would be a useful next step. Of course, when the file is ingested there will need to be error checking there, too. On lines 42-44, wouldn't the nil pointer issue be that the directory didn't exist? So far the code seems to handle that, but I'm probably missing a few things. Leam On 11/16/21 08:40, Brian Candler wrote:
(BTW, sharing your code on play.golang.org makes it easier to format and read) On Tuesday, 16 November 2021 at 14:11:54 UTC leam...@gmail.com wrote: 14 func exists(filepath string) bool { 15 if _, err := os.Stat(filepath); errors.Is(err, fs.ErrNotExist) { 16 return false 17 } 18 return true 19 } You are silently ignoring all errors here, apart from fs.ErrNotExist. (You already identified that problem in your isDir function). Basically there are three possible results: file exists, file doesn't exist, or something went wrong. The traditional way to return that would be as a pair of values (bool, err) Alternatively, it might be reasonable to panic(err) on any other non-nil error here. 42 if exists(*custom_datadir) { 43 customData = isDir(*custom_datadir) 44 } Screams "pointer not checked for nil" to me.
-- Systems Programmer (reuel.net/resume) Scribe: The Domici War (domiciwar.net) General Ne'er-do-well (github.com/LeamHall) -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6af418b2-767c-435b-87e7-9ec09c82dd76%40gmail.com.