nativehttp

Simple interface to the native http client
Log | Files | Refs | README | LICENSE

core.go (558B)


      1 // Package core offers a minimal set of core functionality like string processing and io.
      2 //
      3 // The purpose is to avoid taking a dependency on large standard library packages in order
      4 // to reduce binary size.
      5 //
      6 // Being highly performant is not a goal, being small and simple is.
      7 // Code is added as needed.
      8 package core
      9 
     10 import "errors"
     11 
     12 // Cleanup executes a fallible function if the captured error is not nil.
     13 func Cleanup(err *error, fn func() error) {
     14 	if err != nil && *err != nil {
     15 		if e := fn(); e != nil {
     16 			*err = errors.Join(*err, e)
     17 		}
     18 	}
     19 }