
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
Simple way to automatically return errors from functions you defer.
// returns "error coming from defer"
package main
import (
"fmt"
"github.com/catmullet/deferror"
)
func main() {
if err := yourLogicHere(); err != nil {
fmt.Println(err)
}
}
// defer function that return error
func deferWithError() error {
return fmt.Errorf("error coming from defer")
}
// function calling defer requires a named variable of interface error
func yourLogicHere() (err error) {
// pass by pointer the error.
defer deferror.As(deferWithError, &err)
return
}
// returns "error coming from defer"
package main
import (
"fmt"
"github.com/catmullet/deferror"
)
func main() {
err, deferError := yourLogicHere()
if err != nil {
fmt.Println(err)
}
if deferError != nil {
fmt.Println(deferError)
}
}
// defer function that return error
func deferWithError() error {
return fmt.Errorf("error coming from defer")
}
// function calling defer requires a named variable of interface error
// you can seperate out the error if you would like. deferror.As will never overwrite the error
// passed in if it is not nil.
func yourLogicHere() (err, deferError error) {
// pass by pointer the error.
defer deferror.As(deferWithError, &deferError)
return
}
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.