FAQ
The "problem" is that callers must be familiar with the error.

I'm using the filesystem as a cache (or spooler) for a web crawler.
The caller try to create a file with a given url. If file already exists,
then the caller is done.
If the file does not exists, download the url and store in the filesystem.


Thanks <am;op

Il giorno martedì 8 marzo 2016 15:44:15 UTC+1, Matt Silverlock ha scritto:
#1. Callers who are not familiar with os.PathError can then perform a
lookup appropriately. Those who don't care can just handle the error
opaquely.
On Tuesday, March 8, 2016 at 3:44:48 AM UTC-8, Manlio Perillo wrote:

Hi.

I have a function Create(path string) that opens a file with the O_CREAT
and O_EXCL flags.
The fact that an error is returned if the file exists is probably part of
the API, so it should be documented. What is the best method?

1) Document that if there is an error, it will be of type *os.PathError.
2) Document that if path exists, the function returns os.ErrExists.
3) Document that if path exists, the function returns an error such that
os.IsExist(err) returns true.
4) Change the function result list from (*os.File, error) to (file
*os.File, ok bool, err error)


Thanks Manlio
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 4 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 8, '16 at 11:44a
activeMar 8, '16 at 3:55p
posts4
users2
websitegolang.org

2 users in discussion

Matt Silverlock: 2 posts Manlio Perillo: 2 posts

People

Translate

site design / logo © 2021 Grokbase