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: multisub.go
    path of file: ./repos/go-ethereum/event
    
    the code of the file until where you have to start completion: // Copyright 2023 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
    
func JoinSubscriptions(subs ...Subscription) Subscription {
	return NewSubscription(func(unsubbed <-chan struct{}) error {
		// Unsubscribe all subscriptions before returning
		defer func() {
			for _, sub := range subs {
				sub.Unsubscribe()
			}
		}()
		// Wait for an error on any of the subscriptions and propagate up
		errc := make(chan error, len(subs))
		for i := range subs {
			go func(sub Subscription) {
				select {
				case err := <-sub.Err():
					if err != nil {
						errc <- err
					}
				case <-unsubbed:
				}
			}(subs[i])
		}

		select {
		case err := <-errc:
			return err
		case <-unsubbed:
			return nil
		}
	})
}