You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: errors.go
    path of file: ./repos/vald/internal/errors
    
    the code of the file until where you have to start completion: //
// Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>
//
// Licensed under the Apache License, Version 2.
    
func Join(errs ...error) error {
	l := len(errs)
	switch l {
	case 0:
		return nil
	case 1:
		return errs[0]
	case 2:
		switch {
		case errs[0] != nil && errs[1] != nil:
			if errs[0] == errs[1] || errors.Is(errs[0], errs[1]) {
				return errs[0]
			}
			var es []error
			switch x := errs[1].(type) {
			case *joinError:
				es = x.errs
			case interface{ Unwrap() []error }:
				es = x.Unwrap()
			default:
				es = []error{errs[1]}
			}
			switch x := errs[0].(type) {
			case *joinError:
				x.errs = append(x.errs, es...)
				return x
			case interface{ Unwrap() []error }:
				return &joinError{errs: append(x.Unwrap(), es...)}
			default:
				return &joinError{errs: []error{errs[0], errs[1]}}
			}
		case errs[0] != nil:
			return errs[0]
		case errs[1] != nil:
			return errs[1]
		}
		return nil
	}
	var e *joinError
	switch x := errs[0].(type) {
	case *joinError:
		e = x
		errs = errs[1:]
	case interface{ Unwrap() []error }:
		e = &joinError{errs: x.Unwrap()}
		errs = errs[1:]
	default:
		e = &joinError{
			errs: make([]error, 0, l),
		}
	}
	for _, err := range errs {
		if err != nil {
			e.errs = append(e.errs, err)
		}
	}
	return e
}