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: corpus.go
    path of file: ./repos/cockroach/pkg/sql/schemachanger/corpus
    
    the code of the file until where you have to start completion: // Copyright 2022 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License

    
func (cc *Collector) UpdateCorpus() error {
	corpusFile, unlockFn, err := cc.openCorpus(true)
	if err != nil {
		return err
	}
	defer unlockFn()
	defer corpusFile.Close()
	err = cc.readCorpusWithFile(corpusFile)
	if err != nil {
		return err
	}
	_, err = corpusFile.Seek(0, io.SeekStart)
	if err != nil {
		return err
	}
	// Combine all the entries.
	entryMap := make(map[string]*scpb.CorpusState)
	for _, entry := range cc.diskState.CorpusArray {
		// If a prefix has been replaced, then skip it
		if _, ok := cc.corpusPrefixes[getCorpusTestPrefix(entry.Name)]; ok {
			continue
		}
		entryMap[entry.Name] = entry
	}
	for _, entry := range cc.corpusEntries {
		entryMap[entry.Name] = entry
	}
	mergedEntries := scpb.CorpusDisk{
		CorpusArray: make([]*scpb.CorpusState, 0, len(entryMap)),
	}
	for _, entry := range entryMap {
		mergedEntries.CorpusArray = append(mergedEntries.CorpusArray, entry)
	}
	// Sort them out.
	sort.SliceStable(mergedEntries.CorpusArray, func(i, j int) bool {
		return mergedEntries.CorpusArray[i].Name < mergedEntries.CorpusArray[j].Name
	})
	// Write the merged entries back
	err = corpusFile.Truncate(0)
	if err != nil {
		return err
	}
	bytes, err := protoutil.Marshal(&mergedEntries)
	if err != nil {
		return err
	}
	_, err = corpusFile.Write(bytes)
	if err != nil {
		return err
	}
	return nil
}