vt-go
vt-go copied to clipboard
don't panic inside the library
I'm not a fun of using panic inside a client library, this could lead to unexpected crashes of code using the library.
https://github.com/VirusTotal/vt-go/blob/e010bf48aaee07eedebfa842258f1f6d1ec3bdd8/vt.go#L74-L79
What about creating a new method like this?
func NewURL(pathFmt string, a ...interface{}) (*url.URLm, error) {
path := fmt.Sprintf(pathFmt, a...)
url, err := url.Parse(path)
if err != nil {
return nil, fmt.Errorf(
"error formatting URL \"%s\": %s",
pathFmt, err)
}
return baseURL.ResolveReference(url), nil
}
Also, all the Must* functions defined in https://github.com/VirusTotal/vt-go/blob/master/object.go
are potentially dangerous, I suggest to deprecated them since they are not used in the main library!
Hello @ludusrusso,
Thank you for your suggestion. Feel free to make a contribution to fix the problem :).
Regards, Marta