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: env.go
    path of file: ./repos/docker-ce/components/engine/vendor/gotest.tools/v3/env
    
    the code of the file until where you have to start completion: /*Package env provides functions to test code that read environment variables
or the current working directory.
*/
package env // import "gotest.tools/v3/env"

import (
	"os"
	"strings"

	"gotest.tools/v3/assert"
	"gotest.tools/v3/internal/cleanup"
)

type helperT interface {
	Helper()
}

// Patch changes the value of an envi
    
func PatchAll(t assert.TestingT, env map[string]string) func() {
	if ht, ok := t.(helperT); ok {
		ht.Helper()
	}
	oldEnv := os.Environ()
	os.Clearenv()

	for key, value := range env {
		assert.NilError(t, os.Setenv(key, value), "setenv %s=%s", key, value)
	}
	clean := func() {
		if ht, ok := t.(helperT); ok {
			ht.Helper()
		}
		os.Clearenv()
		for key, oldVal := range ToMap(oldEnv) {
			assert.NilError(t, os.Setenv(key, oldVal), "setenv %s=%s", key, oldVal)
		}
	}
	cleanup.Cleanup(t, clean)
	return clean
}