In this basic example, we to see if a before interacting with it (otherwise something’s not going to work as expected). We leverage the power of the os standard library and first use the Stat() function which although it’s usually used to get information about a , we’re only looking at the errors.
We can’t just check for err == nil because any number of errors could be returned so we pass it to IsNotExists() to confirm that it’s an error because the file does not exist.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here