func (s *session) Close() {
	if IsRecording() && len(s.recording) != 0 {
		_ = s.file.Parse()
		s.file.AddRecording(s.recordingName, s.recording)
		s.file.WriteRecordingFile()
	}
	clearPooledConnections()
}
Close ends this session, writing any recording file and clearing state.
package copyist
import (
	"fmt"
	"os"
)
type session struct {
	recording recording
	index int
	file *recordingFile
	recordingName string
	isInit bool
}
var currentSession *session
func IsOpen() bool {
	return currentSession != nil
}
func newSession(pathName, recordingName string) *session {
	return &session{
		recording:     recording{},
		file:          newRecordingFile(pathName),
		recordingName: recordingName,
	}
}
func (s *session) OnDriverOpen(driver *proxyDriver) {
	if s.isInit {
		return
	}
	s.isInit = true
	if IsRecording() {
		if sessionInit != nil {
			sessionInit()
		}
	} else {
		if _, err := os.Stat(s.file.pathName); !os.IsNotExist(err) {
			if err = s.file.Parse(); err != nil {
				s.panicf("error parsing recording file: %v", err)
			}
		}
		s.recording = s.file.GetRecording(s.recordingName)
		if s.recording == nil {
			s.panicf("no recording exists with this name: %v", s.recordingName)
		}
	}
	clearPooledConnections()
}
func (s *session) AddRecord(rec *record) {
	s.recording = append(s.recording, rec)
}
func (s *session) VerifyRecordWithStringArg(recordTyp recordType, arg string) *record {
	rec := s.VerifyRecord(recordTyp)
	if rec.Args[0].(string) != arg {
		s.panicf(
			"mismatched argument to %s, expected %s, got %s\n\n"+
				"Do you need to regenerate the recording with the -record flag?",
			recordTyp.String(), arg, rec.Args[0].(string))
	}
	return rec
}
func (s *session) VerifyRecord(recordTyp recordType) *record {
	if s.index >= len(s.recording) {
		s.panicf(
			"too many calls to %s\n\n"+
				"Do you need to regenerate the recording with the -record flag?", recordTyp.String())
	}
	rec := s.recording[s.index]
	if rec.Typ != recordTyp {
		s.panicf(
			"unexpected call to %s\n\n"+
				"Do you need to regenerate the recording with the -record flag?", recordTyp.String())
	}
	s.index++
	return rec
}