Skip to content

Commit

Permalink
added MemFile.PrintForCallStack
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Jul 2, 2024
1 parent b8d04cd commit d3679a7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion memfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,18 @@ func MemFilesAsFileReaders(memFiles []MemFile) []FileReader {
return fileReaders
}

// String returns the name and meta information for the FileReader.
// String returns the metadata of the file formatted as a string.
// String implements the fmt.Stringer interface.
func (f MemFile) String() string {
return fmt.Sprintf("MemFile{name: `%s`, size: %d}", f.FileName, len(f.FileData))
}

// PrintForCallStack prints the metadata of the file
// for call stack errors.
func (f MemFile) PrintForCallStack(w io.Writer) {
_, _ = io.WriteString(w, f.String())
}

// Name returns the name of the file.
// If FileName contains a slash or backslash
// then only the part after it will be returned.
Expand Down

0 comments on commit d3679a7

Please sign in to comment.