Package nexus

   Gregory Vinčić
   Last modified: 2026-06-18
   Published: 2019


Abstract

   Simplifies error handling in Go by providing functions using nexus
   pattern converging on an error.


Table of Contents

1   Quick start  ....................................................
2   Examples  .......................................................
2.1   Printer  ......................................................
2.2   Stepper  ......................................................
3   Appendix  .......................................................
3.1   Changelog  ....................................................




1 Quick start

       go get sogvin.com/nexus


2 Examples

   More details are found in the API documentation.

2.1 Printer

       func RenderSomething(w io.Writer) error {
           p, err := nexus.NewPrinter(os.Stdout)
           p.Print("My long")
           p.Println("text")
           p.Printf("Hello, %s", "World")
           return *err
       }

2.2 Stepper

   Stepper simplifies multistep flow.  The cyclomatic complexity is
   always 1 for functions using the nexus Stepper.  This simplifies
   testing.  I.e. test one happy path and one sad path.

       func multiStepFlow() (string, error) {
           var (
             err  error
             next = NewStepper(&err)
           )

           var a []byte
           next.Step(func() {
             a, err = DoSomething()
           })

           var b []byte
           next.Stepf("create: %w", func() {
             b, err = Create(a)
           })

           var c string
           next.Stepf("transform: %w", func() {
             c, err = Transform(b)
           })

           return c, err
       }


3 Appendix

3.1 Changelog

   All notable changes to this project will be documented in this file.
   This project adheres to semantic versioning.

   0.8.0 - 2025-12-22

   - Move to sogvin.com/nexus

   0.7.0 - 2024-02-14

   - Bump year in license
   - Stepf takes format with optional %w for wrapping errors

   0.6.0 - 2022-08-13

   - Add type Writer

   0.5.1 - 2021-04-22

   - Add MIT license

   0.5.0 - 2021-04-22

   - Add type Stepper
   - Add type Failure

   0.4.0 - 2020-02-08

   - Add Func First, selecting first error

   0.3.0 - 2019-12-31

   - Printer.Written type changed to int64

   0.2.0 - 2019-12-28

   - Add Type Printer wrapping a writer
   - Remove specific print funcs

   0.1.0 - 2019-11-26

   - Add Print, Println, Printf, Fprintf and Fprintln